{"id":3332,"date":"2023-10-25T18:46:49","date_gmt":"2023-10-25T10:46:49","guid":{"rendered":"https:\/\/white-night.club\/?p=3332"},"modified":"2023-11-09T11:07:46","modified_gmt":"2023-11-09T03:07:46","slug":"ad98","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/25\/ad98\/","title":{"rendered":"176.\u00a0\u7b2c\u4e8c\u9ad8\u7684\u85aa\u6c34"},"content":{"rendered":"\n<p><code>Employee<\/code>&nbsp;\u8868\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+-------------+------+\n| Column Name | Type |\n+-------------+------+\n| id          | int  |\n| salary      | int  |\n+-------------+------+\n\u5728 SQL \u4e2d\uff0cid \u662f\u8fd9\u4e2a\u8868\u7684\u4e3b\u952e\u3002\n\u8868\u7684\u6bcf\u4e00\u884c\u5305\u542b\u5458\u5de5\u7684\u5de5\u8d44\u4fe1\u606f\u3002\n<\/pre>\n\n\n\n<p>\u67e5\u8be2\u5e76\u8fd4\u56de&nbsp;<code>Employee<\/code>&nbsp;\u8868\u4e2d\u7b2c\u4e8c\u9ad8\u7684\u85aa\u6c34 \u3002\u5982\u679c\u4e0d\u5b58\u5728\u7b2c\u4e8c\u9ad8\u7684\u85aa\u6c34\uff0c\u67e5\u8be2\u5e94\u8be5\u8fd4\u56de&nbsp;<code>null(Pandas \u5219\u8fd4\u56de None)<\/code>&nbsp;\u3002<\/p>\n\n\n\n<p>\u67e5\u8be2\u7ed3\u679c\u5982\u4e0b\u4f8b\u6240\u793a\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>\nEmployee \u8868\uff1a\n+----+--------+\n| id | salary |\n+----+--------+\n| 1  | 100    |\n| 2  | 200    |\n| 3  | 300    |\n+----+--------+\n<strong>\u8f93\u51fa\uff1a<\/strong>\n+---------------------+\n| SecondHighestSalary |\n+---------------------+\n| 200                 |\n+---------------------+\n<\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 2\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>\nEmployee \u8868\uff1a\n+----+--------+\n| id | salary |\n+----+--------+\n| 1  | 100    |\n+----+--------+\n<strong>\u8f93\u51fa\uff1a<\/strong>\n+---------------------+\n| SecondHighestSalary |\n+---------------------+\n| null                |\n+---------------------+<\/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>ifnull<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u5355\u7eaf\u627e\u7b2c2\u9ad8\u4e0d\u96be\uff0c\u76f4\u63a5\u7a97\u53e3\u51fd\u6570\u5c31\u5b8c\u4e8b\u4e86\u3002<\/p>\n\n\n\n<p>\u95ee\u9898\u662f\u8fd4\u56denull\uff0cifnull\u5230\u5e95\u52a0\u5728\u54ea\u91cc\u597d\u5462\uff1f\u5982\u679c\u76f4\u63a5\u8fd9\u4e48\u5199<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\nSELECT ifnull(salary,null) AS SecondHighestSalary\n  FROM(\n    (SELECT salary,\n    dense_rank()over(order by salary DESC) AS rk\n    FROM employee)\n  ) t\nWHERE rk=2<\/code><\/pre>\n\n\n\n<p>\u5f88\u5408\u7406\uff0cifnull\u53bb\u5224\u65adsalary\u662f\u5426\u4e3anull\u3002\u4f46\u662f\u5b83\u8fc7\u4e0d\u4e86\u6837\u4f8b\uff0c\u4f60\u56de\u53d1\u73b0\u6700\u540e\u8fd8\u662f\u65e0\u6cd5\u8fd4\u56de\u7a7a\u3002\u8fd9\u610f\u5473\u7740ifnull\u6ca1\u751f\u6548\u3002<\/p>\n\n\n\n<p>\u4e0d\u5f97\u4e0d\u8bf4leetcode\u9898\u89e3\u4e5f\u5f88\u91cd\u8981\u3002\u6211\u78b0\u5230\u8fd9\u4e2a\u95ee\u9898\u5c31\u53bb\u9898\u89e3\u91cc\u627e\uff0c\u6700\u540e\u7ec8\u4e8e\u660e\u767d\u4e86\u4e3a\u5565\uff0c\u8fd9\u91cc\u653e\u4e0a\u6211\u81ea\u5df1\u7684\u603b\u7ed3\uff1a<a rel=\"noreferrer noopener\" href=\"https:\/\/white-night.club\/index.php\/2023\/10\/25\/db12\/\" target=\"_blank\"><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0086ff\" class=\"has-inline-color\">MySQL:IFNULL\u65e0\u6cd5\u8fd4\u56denull\u7684\u60c5\u51b5<\/mark><\/a><\/p>\n\n\n\n<p>\u7b80\u7b54\u6765\u8bf4\uff0c\u52a0\u4e2a\u805a\u5408\u51fd\u6570\u5373\u53ef\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\">\n<p><\/p>\n<\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\nSELECT ifnull(MAX(salary),null) AS SecondHighestSalary\n  FROM(\n    (SELECT salary,\n    dense_rank()over(order by salary DESC) AS rk\n    FROM employee)\n  ) t\nWHERE rk=2<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\u7a97\u53e3\u51fd\u6570\u548cifnull<\/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\/3332"}],"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=3332"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/3332\/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=3332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=3332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=3332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}