{"id":4326,"date":"2023-11-08T10:35:30","date_gmt":"2023-11-08T02:35:30","guid":{"rendered":"https:\/\/white-night.club\/?p=4326"},"modified":"2023-11-09T11:07:41","modified_gmt":"2023-11-09T03:07:41","slug":"ad139","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/11\/08\/ad139\/","title":{"rendered":"1084.\u00a0\u9500\u552e\u5206\u6790III"},"content":{"rendered":"\n<p>\u8868\uff1a&nbsp;<code>Product<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+--------------+---------+\n| Column Name  | Type    |\n+--------------+---------+\n| product_id   | int     |\n| product_name | varchar |\n| unit_price   | int     |\n+--------------+---------+\nproduct_id \u662f\u8be5\u8868\u7684\u4e3b\u952e\uff08\u5177\u6709\u552f\u4e00\u503c\u7684\u5217\uff09\u3002\n\u8be5\u8868\u7684\u6bcf\u4e00\u884c\u663e\u793a\u6bcf\u4e2a\u4ea7\u54c1\u7684\u540d\u79f0\u548c\u4ef7\u683c\u3002\n<\/pre>\n\n\n\n<p>\u8868\uff1a<code>Sales<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+-------------+---------+\n| Column Name | Type    |\n+-------------+---------+\n| seller_id   | int     |\n| product_id  | int     |\n| buyer_id    | int     |\n| sale_date   | date    |\n| quantity    | int     |\n| price       | int     |\n+------ ------+---------+\n\u8fd9\u4e2a\u8868\u53ef\u80fd\u6709\u91cd\u590d\u7684\u884c\u3002\nproduct_id \u662f Product \u8868\u7684\u5916\u952e\uff08reference \u5217\uff09\u3002\n\u8be5\u8868\u7684\u6bcf\u4e00\u884c\u5305\u542b\u5173\u4e8e\u4e00\u4e2a\u9500\u552e\u7684\u4e00\u4e9b\u4fe1\u606f\u3002\n<\/pre>\n\n\n\n<p>\u7f16\u5199\u89e3\u51b3\u65b9\u6848\uff0c\u62a5\u544a<code>2019\u5e74\u6625\u5b63<\/code>\u624d\u552e\u51fa\u7684\u4ea7\u54c1\u3002\u5373<strong>\u4ec5<\/strong>\u5728<code><strong>2019-01-01<\/strong><\/code>\u81f3<code><strong>2019-03-31<\/strong><\/code>\uff08\u542b\uff09\u4e4b\u95f4\u51fa\u552e\u7684\u5546\u54c1\u3002<\/p>\n\n\n\n<p>\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\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>\nProduct table:\n+------------+--------------+------------+\n| product_id | product_name | unit_price |\n+------------+--------------+------------+\n| 1          | S8           | 1000       |\n| 2          | G4           | 800        |\n| 3          | iPhone       | 1400       |\n+------------+--------------+------------+\n<code>Sales <\/code>table:\n+-----------+------------+----------+------------+----------+-------+\n| seller_id | product_id | buyer_id | sale_date  | quantity | price |\n+-----------+------------+----------+------------+----------+-------+\n| 1         | 1          | 1        | 2019-01-21 | 2        | 2000  |\n| 1         | 2          | 2        | 2019-02-17 | 1        | 800   |\n| 2         | 2          | 3        | 2019-06-02 | 1        | 800   |\n| 3         | 3          | 4        | 2019-05-13 | 2        | 2800  |\n+-----------+------------+----------+------------+----------+-------+\n<strong>\u8f93\u51fa\uff1a<\/strong>\n+-------------+--------------+\n| product_id  | product_name |\n+-------------+--------------+\n| 1           | S8           |\n+-------------+--------------+\n<strong>\u89e3\u91ca:<\/strong>\nid\u4e3a1\u7684\u4ea7\u54c1\u4ec5\u57282019\u5e74\u6625\u5b63\u9500\u552e\u3002\nid\u4e3a2\u7684\u4ea7\u54c1\u57282019\u5e74\u6625\u5b63\u9500\u552e\uff0c\u4f46\u4e5f\u57282019\u5e74\u6625\u5b63\u4e4b\u540e\u9500\u552e\u3002\nid 3\u7684\u4ea7\u54c1\u57282019\u5e74\u6625\u5b63\u4e4b\u540e\u9500\u552e\u3002\n\u6211\u4eec\u53ea\u9000\u56de\u4ea7\u54c11\uff0c\u56e0\u4e3a\u5b83\u662f2019\u5e74\u6625\u5b63\u624d\u9500\u552e\u7684\u4ea7\u54c1\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>COUNT<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u901a\u8fc7COUNT\u6765\u7edf\u8ba1xxx\u51fa\u73b0\u8fc7\u7684\u6b21\u6570\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u5b9e\u5728\u662f\u6709\u70b9\u5999\u3002\u6bd4\u5982xxx\u6570\u636e\u6ca1\u51fa\u73b0\u8fc7\u7684\u8bdd\u90a3\u5c31\u4ee4COUNT=0\u3002\u6709\u51fa\u73b0\u8fc7\u5c31\u5927\u4e8e\u7b49\u4e8e1\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\r\nSELECT A.product_id,B.product_name\r\nFROM Sales AS A \r\nLEFT JOIN Product AS B \r\nON A.product_id=B.product_id\r\nGROUP BY A.product_id\r\nHAVING COUNT(IF(A.sale_date &lt; '2019-01-01' OR A.sale_date>'2019-03-31',1,NULL))=0<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1aCOUNT<\/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\/4326"}],"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=4326"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/4326\/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=4326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=4326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=4326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}