{"id":3089,"date":"2023-10-19T09:04:37","date_gmt":"2023-10-19T01:04:37","guid":{"rendered":"https:\/\/white-night.club\/?p=3089"},"modified":"2023-11-09T11:07:48","modified_gmt":"2023-11-09T03:07:48","slug":"ad74","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/19\/ad74\/","title":{"rendered":"1069.&nbsp;\u4ea7\u54c1\u9500\u552e\u5206\u6790 II"},"content":{"rendered":"\n<p>\u9500\u552e\u8868\uff1a<code>Sales<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+-------------+-------+\n| Column Name | Type  |\n+-------------+-------+\n| sale_id     | int   |\n| product_id  | int   |\n| year        | int   |\n| quantity    | int   |\n| price       | int   |\n+-------------+-------+\nsale_id \u662f\u8fd9\u4e2a\u8868\u7684\u4e3b\u952e\uff08\u5177\u6709\u552f\u4e00\u503c\u7684\u5217\uff09\u3002\nproduct_id \u662f Product \u8868\u7684\u5916\u952e\uff08reference \u5217\uff09\u3002\n\u8be5\u8868\u7684\u6bcf\u4e00\u884c\u663e\u793a\u4ea7\u54c1product_id\u5728\u67d0\u4e00\u5e74\u7684\u9500\u552e\u60c5\u51b5\u3002\n\u8bf7\u6ce8\u610f\u4ef7\u683c\u662f\u6bcf\u5355\u4f4d\u7684\u3002\n<\/pre>\n\n\n\n<p>\u4ea7\u54c1\u8868\uff1a<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+--------------+---------+\nproduct_id \u662f\u8fd9\u4e2a\u8868\u7684\u4e3b\u952e\uff08\u5177\u6709\u552f\u4e00\u503c\u7684\u5217\uff09\u3002\n\u8be5\u8868\u7684\u6bcf\u4e00\u884c\u8868\u793a\u6bcf\u79cd\u4ea7\u54c1\u7684\u4ea7\u54c1\u540d\u79f0\u3002\n<\/pre>\n\n\n\n<p>\u7f16\u5199\u89e3\u51b3\u65b9\u6848\uff0c\u7edf\u8ba1\u6bcf\u4e2a\u4ea7\u54c1\u7684\u9500\u552e\u603b\u91cf\u3002<\/p>\n\n\n\n<p>\u8fd4\u56de\u7ed3\u679c\u8868&nbsp;<strong>\u65e0\u987a\u5e8f\u8981\u6c42<\/strong>&nbsp;\u3002<\/p>\n\n\n\n<p>\u7ed3\u679c\u683c\u5f0f\u5982\u4e0b\u4f8b\u5b50\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\"><code><strong>\u8f93\u5165\uff1a<\/strong>\nSales<\/code> \u8868\uff1a\n+---------+------------+------+----------+-------+\n| sale_id | product_id | year | quantity | price |\n+---------+------------+------+----------+-------+ \n| 1       | 100        | 2008 | 10       | 5000  |\n| 2       | 100        | 2009 | 12       | 5000  |\n| 7       | 200        | 2011 | 15       | 9000  |\n+---------+------------+------+----------+-------+\nProduct \u8868\uff1a\n+------------+--------------+\n| product_id | product_name |\n+------------+--------------+\n| 100        | Nokia        |\n| 200        | Apple        |\n| 300        | Samsung      |\n+------------+--------------+\n<strong>\u8f93\u51fa\uff1a<\/strong>\n+--------------+----------------+\n| product_id   | total_quantity |\n+--------------+----------------+\n| 100          | 22             |\n| 200          | 15             |\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>GROUP BY<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u76f4\u63a5\u6839\u636eproduct_id\u7136\u540eGROUP BY\u5206\u7ec4\u5373\u53ef\uff0cProduct\u8868\u90fd\u7528\u4e0d\u4e0a\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\r\nSELECT A.product_id,SUM(A.quantity) AS total_quantity\r\nFROM Sales AS A\r\nGROUP BY product_id<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1aGROUP BY<\/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\/3089"}],"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=3089"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/3089\/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=3089"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=3089"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=3089"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}