{"id":2205,"date":"2023-10-10T09:10:31","date_gmt":"2023-10-10T01:10:31","guid":{"rendered":"https:\/\/white-night.club\/?p=2205"},"modified":"2023-11-09T11:07:51","modified_gmt":"2023-11-09T03:07:51","slug":"ad35","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/10\/ad35\/","title":{"rendered":"1158.\u00a0\u5e02\u573a\u5206\u6790 I"},"content":{"rendered":"\n<p>\u8868\uff1a&nbsp;<code>Users<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+----------------+---------+\n| Column Name    | Type    |\n+----------------+---------+\n| user_id        | int     |\n| join_date      | date    |\n| favorite_brand | varchar |\n+----------------+---------+\nuser_id \u662f\u6b64\u8868\u4e3b\u952e\uff08\u5177\u6709\u552f\u4e00\u503c\u7684\u5217\uff09\u3002\n\u8868\u4e2d\u63cf\u8ff0\u4e86\u8d2d\u7269\u7f51\u7ad9\u7684\u7528\u6237\u4fe1\u606f\uff0c\u7528\u6237\u53ef\u4ee5\u5728\u6b64\u7f51\u7ad9\u4e0a\u8fdb\u884c\u5546\u54c1\u4e70\u5356\u3002\n<\/pre>\n\n\n\n<p>\u8868\uff1a&nbsp;<code>Orders<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+---------------+---------+\n| Column Name   | Type    |\n+---------------+---------+\n| order_id      | int     |\n| order_date    | date    |\n| item_id       | int     |\n| buyer_id      | int     |\n| seller_id     | int     |\n+---------------+---------+\norder_id \u662f\u6b64\u8868\u4e3b\u952e\uff08\u5177\u6709\u552f\u4e00\u503c\u7684\u5217\uff09\u3002\nitem_id \u662f Items \u8868\u7684\u5916\u952e\uff08reference \u5217\uff09\u3002\n\uff08buyer_id\uff0cseller_id\uff09\u662f User \u8868\u7684\u5916\u952e\u3002\n<\/pre>\n\n\n\n<p>\u8868\uff1a<code>Items<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+---------------+---------+\n| Column Name   | Type    |\n+---------------+---------+\n| item_id       | int     |\n| item_brand    | varchar |\n+---------------+---------+\nitem_id \u662f\u6b64\u8868\u7684\u4e3b\u952e\uff08\u5177\u6709\u552f\u4e00\u503c\u7684\u5217\uff09\u3002\n<\/pre>\n\n\n\n<p>\u7f16\u5199\u89e3\u51b3\u65b9\u6848\u627e\u51fa\u6bcf\u4e2a\u7528\u6237\u7684\u6ce8\u518c\u65e5\u671f\u548c\u5728&nbsp;<strong><code>2019<\/code>&nbsp;<\/strong>\u5e74\u4f5c\u4e3a\u4e70\u5bb6\u7684\u8ba2\u5355\u603b\u6570\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>\u67e5\u8be2\u7ed3\u679c\u683c\u5f0f\u5982\u4e0b\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>\nUsers \u8868:\n+---------+------------+----------------+\n| user_id | join_date  | favorite_brand |\n+---------+------------+----------------+\n| 1       | 2018-01-01 | Lenovo         |\n| 2       | 2018-02-09 | Samsung        |\n| 3       | 2018-01-19 | LG             |\n| 4       | 2018-05-21 | HP             |\n+---------+------------+----------------+\nOrders \u8868:\n+----------+------------+---------+----------+-----------+\n| order_id | order_date | item_id | buyer_id | seller_id |\n+----------+------------+---------+----------+-----------+\n| 1        | 2019-08-01 | 4       | 1        | 2         |\n| 2        | 2018-08-02 | 2       | 1        | 3         |\n| 3        | 2019-08-03 | 3       | 2        | 3         |\n| 4        | 2018-08-04 | 1       | 4        | 2         |\n| 5        | 2018-08-04 | 1       | 3        | 4         |\n| 6        | 2019-08-05 | 2       | 2        | 4         |\n+----------+------------+---------+----------+-----------+\nItems \u8868:\n+---------+------------+\n| item_id | item_brand |\n+---------+------------+\n| 1       | Samsung    |\n| 2       | Lenovo     |\n| 3       | LG         |\n| 4       | HP         |\n+---------+------------+\n<strong>\u8f93\u51fa\uff1a<\/strong>\n+-----------+------------+----------------+\n| buyer_id  | join_date  | orders_in_2019 |\n+-----------+------------+----------------+\n| 1         | 2018-01-01 | 1              |\n| 2         | 2018-02-09 | 2              |\n| 3         | 2018-01-19 | 0              |\n| 4         | 2018-05-21 | 0              |\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>\u591a\u8868\u67e5\u8be2<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u591a\u8868\u67e5\u8be2\u786e\u5b9e\u4e0d\u597d\u7406\u89e3\u3002<\/p>\n\n\n\n<p>\u8981\u8ba1\u7b97Orders\u8868\u4e2dorders\u7684\u603b\u6570\u3002\u90a3\u5c31\u6839\u636euser_id\uff08GROUP BY\uff09\u53bb\u5bf9order_id\u51fa\u73b0\u7684\u6b21\u6570\u8fdb\u884c\u5206\u7ec4\u3002\u8fd8\u8981\u7528\u5230year\uff08\uff09\u51fd\u6570\u3002\u4e0d\u8fc7\u7528LIKE\u4e5f\u884c\u3002<\/p>\n\n\n\n<p>item\u8868\u8c8c\u4f3c\u7528\u4e0d\u4e0a\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\nSELECT user_id as buyer_id,join_date,COUNT(order_id) AS orders_in_2019\nFROM Users\nLEFT JOIN Orders\nON Users.user_id=Orders.buyer_id AND year(order_date)=2019\nGROUP BY user_id<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\u591a\u8868\u67e5\u8be2<\/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\/2205"}],"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=2205"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2205\/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=2205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=2205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=2205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}