{"id":2262,"date":"2023-10-11T08:58:13","date_gmt":"2023-10-11T00:58:13","guid":{"rendered":"https:\/\/white-night.club\/?p=2262"},"modified":"2023-11-09T11:07:50","modified_gmt":"2023-11-09T03:07:50","slug":"ad36","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/11\/ad36\/","title":{"rendered":"1873.\u00a0\u8ba1\u7b97\u7279\u6b8a\u5956\u91d1"},"content":{"rendered":"\n<p>\u8868:&nbsp;<code>Employees<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+-------------+---------+\n| \u5217\u540d        | \u7c7b\u578b     |\n+-------------+---------+\n| employee_id | int     |\n| name        | varchar |\n| salary      | int     |\n+-------------+---------+\nemployee_id \u662f\u8fd9\u4e2a\u8868\u7684\u4e3b\u952e(\u5177\u6709\u552f\u4e00\u503c\u7684\u5217)\u3002\n\u6b64\u8868\u7684\u6bcf\u4e00\u884c\u7ed9\u51fa\u4e86\u96c7\u5458id \uff0c\u540d\u5b57\u548c\u85aa\u6c34\u3002\n<\/pre>\n\n\n\n<p>\u7f16\u5199\u89e3\u51b3\u65b9\u6848\uff0c\u8ba1\u7b97\u6bcf\u4e2a\u96c7\u5458\u7684\u5956\u91d1\u3002\u5982\u679c\u4e00\u4e2a\u96c7\u5458\u7684 id \u662f&nbsp;<strong>\u5947\u6570<\/strong>&nbsp;\u5e76\u4e14\u4ed6\u7684\u540d\u5b57\u4e0d\u662f\u4ee5&nbsp;<code>'M'<\/code>&nbsp;<strong>\u5f00\u5934<\/strong>\uff0c\u90a3\u4e48\u4ed6\u7684\u5956\u91d1\u662f\u4ed6\u5de5\u8d44\u7684&nbsp;<code>100%<\/code>&nbsp;\uff0c\u5426\u5219\u5956\u91d1\u4e3a&nbsp;<code>0<\/code>&nbsp;\u3002<\/p>\n\n\n\n<p>\u8fd4\u56de\u7684\u7ed3\u679c\u6309\u7167&nbsp;<code>employee_id<\/code>&nbsp;\u6392\u5e8f\u3002<\/p>\n\n\n\n<p>\u8fd4\u56de\u7ed3\u679c\u683c\u5f0f\u5982\u4e0b\u9762\u7684\u4f8b\u5b50\u6240\u793a\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>\nEmployees \u8868:\n+-------------+---------+--------+\n| employee_id | name    | salary |\n+-------------+---------+--------+\n| 2           | Meir    | 3000   |\n| 3           | Michael | 3800   |\n| 7           | Addilyn | 7400   |\n| 8           | Juan    | 6100   |\n| 9           | Kannon  | 7700   |\n+-------------+---------+--------+\n<strong>\u8f93\u51fa\uff1a<\/strong>\n+-------------+-------+\n| employee_id | bonus |\n+-------------+-------+\n| 2           | 0     |\n| 3           | 0     |\n| 7           | 7400  |\n| 8           | 0     |\n| 9           | 7700  |\n+-------------+-------+\n<strong>\u89e3\u91ca\uff1a<\/strong>\n\u56e0\u4e3a\u96c7\u5458id\u662f\u5076\u6570\uff0c\u6240\u4ee5\u96c7\u5458id \u662f2\u548c8\u7684\u4e24\u4e2a\u96c7\u5458\u5f97\u5230\u7684\u5956\u91d1\u662f0\u3002\n\u96c7\u5458id\u4e3a3\u7684\u56e0\u4e3a\u4ed6\u7684\u540d\u5b57\u4ee5'M'\u5f00\u5934\uff0c\u6240\u4ee5\uff0c\u5956\u91d1\u662f0\u3002\n\u5176\u4ed6\u7684\u96c7\u5458\u5f97\u5230\u4e86\u767e\u5206\u4e4b\u767e\u7684\u5956\u91d1\u3002<\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u89e3\u9898\u601d\u8def<\/p>\n<cite><em>SELECT&#8230;IF&#8230;FROM<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u4e0d\u77e5\u9053if\u8fd8\u80fd\u8fd9\u4e48\u7528\u3002\u4e00\u76f4\u5728\u60f3\u600e\u4e48\u5efa\u4e00\u4e2a\u65b0\u5217\uff0c\u7ed3\u679c\u538b\u6839\u4e0d\u7528\u601d\u8003\u8fd9\u4e2a\u95ee\u9898\u3002<\/p>\n\n\n\n<p>if\u8bed\u53e5\u6211\u4f1a\u5199\uff0c\u8fd9\u6ca1\u4ec0\u4e48\u95ee\u9898\u3002\u4f46\u662f\u628aif\u653eselect\u91cc\u9762\u8fd8\u662f\u7b2c\u4e00\u6b21\u7528\u3002\u5982\u679c\u628aif\u653eFROM\u540e\u9762\uff0c\u90a3\u4e0d\u7b26\u5408if\u6761\u4ef6\u7684\u5c31\u4e0d\u4f1a\u88abSELECT\u5230\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\r\nSELECT employee_id,\r\nif(employee_id%2!=0 AND name NOT LIKE 'M%',salary, 0) AS bonus\r\nFROM Employees \r\nORDER BY employee_id\r<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1aSelect.. if<\/p>\n","protected":false},"author":1,"featured_media":2827,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[42,25],"tags":[38],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2262"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=2262"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2262\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/2827"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=2262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=2262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=2262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}