{"id":3562,"date":"2023-10-27T09:38:27","date_gmt":"2023-10-27T01:38:27","guid":{"rendered":"https:\/\/white-night.club\/?p=3562"},"modified":"2023-11-09T11:07:45","modified_gmt":"2023-11-09T03:07:45","slug":"ad102","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/27\/ad102\/","title":{"rendered":"1821.\u00a0\u5bfb\u627e\u4eca\u5e74\u5177\u6709\u6b63\u6536\u5165\u7684\u5ba2\u6237"},"content":{"rendered":"\n<p>\u8868\uff1a<code>Customers<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+--------------+------+\n| Column Name  | Type |\n+--------------+------+\n| customer_id  | int  |\n| year         | int  |\n| revenue      | int  |\n+--------------+------+\n(customer_id, year) \u662f\u8be5\u8868\u7684\u4e3b\u952e\uff08\u5177\u6709\u552f\u4e00\u503c\u7684\u5217\u7684\u7ec4\u5408\uff09\u3002\n\u8fd9\u4e2a\u8868\u5305\u542b\u5ba2\u6237 ID \u548c\u4e0d\u540c\u5e74\u4efd\u7684\u5ba2\u6237\u6536\u5165\u3002\n\u6ce8\u610f\uff0c\u8fd9\u4e2a\u6536\u5165\u53ef\u80fd\u662f\u8d1f\u6570\u3002\n<\/pre>\n\n\n\n<p>\u7f16\u5199\u4e00\u4e2a\u89e3\u51b3\u65b9\u6848\u6765\u62a5\u544a 2021 \u5e74\u5177\u6709&nbsp;<strong>\u6b63\u6536\u5165<\/strong>&nbsp;\u7684\u5ba2\u6237\u3002<\/p>\n\n\n\n<p>\u53ef\u4ee5\u4ee5&nbsp;<strong>\u4efb\u610f\u987a\u5e8f<\/strong>&nbsp;\u8fd4\u56de\u7ed3\u679c\u8868\u3002<\/p>\n\n\n\n<p>\u7ed3\u679c\u683c\u5f0f\u5982\u4e0b\u793a\u4f8b\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>Input:<\/strong>\nCustomers\n+-------------+------+---------+\n| customer_id | year | revenue |\n+-------------+------+---------+\n| 1           | 2018 | 50      |\n| 1           | 2021 | 30      |\n| 1           | 2020 | 70      |\n| 2           | 2021 | -50     |\n| 3           | 2018 | 10      |\n| 3           | 2016 | 50      |\n| 4           | 2021 | 20      |\n+-------------+------+---------+\n\n<strong>Output:<\/strong>\n+-------------+\n| customer_id |\n+-------------+\n| 1           |\n| 4           |\n+-------------+\n\u5ba2\u6237 1 \u5728 2021 \u5e74\u7684\u6536\u5165\u7b49\u4e8e 30 \u3002\n\u5ba2\u6237 2 \u5728 2021 \u5e74\u7684\u6536\u5165\u7b49\u4e8e -50 \u3002\n\u5ba2\u6237 3 \u5728 2021 \u5e74\u6ca1\u6709\u6536\u5165\u3002\n\u5ba2\u6237 4 \u5728 2021 \u5e74\u7684\u6536\u5165\u7b49\u4e8e 20 \u3002\n\u56e0\u6b64\uff0c\u53ea\u6709\u5ba2\u6237 1 \u548c 4 \u5728 2021 \u5e74\u6709\u6b63\u6536\u5165\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>\u6478\u9c7c\u9898<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u8fd9\u79cd\u7b80\u5355\u7684\u9898\u90a3\u80af\u5b9a\u662f\u8981\u4e00\u6b21\u8fc7\u5600\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\r\nSELECT customer_id\r\nFROM Customers\r\nWHERE year=2021\r\nGROUP BY customer_id\r\nHAVING SUM(revenue)>0<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\u6478\u9c7c\u9898<\/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\/3562"}],"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=3562"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/3562\/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=3562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=3562"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=3562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}