{"id":2267,"date":"2023-10-11T09:32:08","date_gmt":"2023-10-11T01:32:08","guid":{"rendered":"https:\/\/white-night.club\/?p=2267"},"modified":"2023-11-09T11:07:50","modified_gmt":"2023-11-09T03:07:50","slug":"ad37","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/11\/ad37\/","title":{"rendered":"1484.\u00a0\u6309\u65e5\u671f\u5206\u7ec4\u9500\u552e\u4ea7\u54c1"},"content":{"rendered":"\n<p>\u8868&nbsp;<code>Activities<\/code>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+-------------+---------+\n| \u5217\u540d         | \u7c7b\u578b    |\n+-------------+---------+\n| sell_date   | date    |\n| product     | varchar |\n+-------------+---------+\n\u8be5\u8868\u6ca1\u6709\u4e3b\u952e(\u5177\u6709\u552f\u4e00\u503c\u7684\u5217)\u3002\u5b83\u53ef\u80fd\u5305\u542b\u91cd\u590d\u9879\u3002\n\u6b64\u8868\u7684\u6bcf\u4e00\u884c\u90fd\u5305\u542b\u4ea7\u54c1\u540d\u79f0\u548c\u5728\u5e02\u573a\u4e0a\u9500\u552e\u7684\u65e5\u671f\u3002\n<\/pre>\n\n\n\n<p>\u7f16\u5199\u89e3\u51b3\u65b9\u6848\u627e\u51fa\u6bcf\u4e2a\u65e5\u671f\u3001\u9500\u552e\u7684\u4e0d\u540c\u4ea7\u54c1\u7684\u6570\u91cf\u53ca\u5176\u540d\u79f0\u3002<br>\u6bcf\u4e2a\u65e5\u671f\u7684\u9500\u552e\u4ea7\u54c1\u540d\u79f0\u5e94\u6309\u8bcd\u5178\u5e8f\u6392\u5217\u3002<br>\u8fd4\u56de\u6309&nbsp;<code>sell_date<\/code>&nbsp;\u6392\u5e8f\u7684\u7ed3\u679c\u8868\u3002<br>\u7ed3\u679c\u8868\u7ed3\u679c\u683c\u5f0f\u5982\u4e0b\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\"><code><strong>\u8f93\u5165\uff1a<\/strong>\nActivities<\/code> \u8868\uff1a\n+------------+-------------+\n| sell_date  | product     |\n+------------+-------------+\n| 2020-05-30 | Headphone   |\n| 2020-06-01 | Pencil      |\n| 2020-06-02 | Mask        |\n| 2020-05-30 | Basketball  |\n| 2020-06-01 | Bible       |\n| 2020-06-02 | Mask        |\n| 2020-05-30 | T-Shirt     |\n+------------+-------------+\n<strong>\u8f93\u51fa\uff1a<\/strong>\n+------------+----------+------------------------------+\n| sell_date  | num_sold | products                     |\n+------------+----------+------------------------------+\n| 2020-05-30 | 3        | Basketball,Headphone,T-shirt |\n| 2020-06-01 | 2        | Bible,Pencil                 |\n| 2020-06-02 | 1        | Mask                         |\n+------------+----------+------------------------------+\n<strong>\u89e3\u91ca\uff1a<\/strong>\n\u5bf9\u4e8e2020-05-30\uff0c\u51fa\u552e\u7684\u7269\u54c1\u662f (Headphone, Basketball, T-shirt)\uff0c\u6309\u8bcd\u5178\u5e8f\u6392\u5217\uff0c\u5e76\u7528\u9017\u53f7 ',' \u5206\u9694\u3002\n\u5bf9\u4e8e2020-06-01\uff0c\u51fa\u552e\u7684\u7269\u54c1\u662f (Pencil, Bible)\uff0c\u6309\u8bcd\u5178\u5e8f\u6392\u5217\uff0c\u5e76\u7528\u9017\u53f7\u5206\u9694\u3002\n\u5bf9\u4e8e2020-06-02\uff0c\u51fa\u552e\u7684\u7269\u54c1\u662f (Mask)\uff0c\u53ea\u9700\u8fd4\u56de\u8be5\u7269\u54c1\u540d\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>GROUP_CONCAT<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u5148\u6765\u770b\u770bGROUP_CONCAT\u7684\u7528\u6cd5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GROUP_CONCAT(&#91;DISTINCT] expr &#91;,expr ...]\r\n             &#91;ORDER BY {unsigned_integer | col_name | expr}\r\n                 &#91;ASC | DESC] &#91;,col_name ...]]\r\n             &#91;SEPARATOR str_val])<\/code><\/pre>\n\n\n\n<p>\u4ee5\u53ca\u5b98\u7f51\u7ed9\u7684\u4f8b\u5b50<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql> SELECT student_name,\r\n         GROUP_CONCAT(DISTINCT test_score\r\n                      ORDER BY test_score DESC SEPARATOR ' ')\r\n       FROM student\r\n       GROUP BY student_name;<\/code><\/pre>\n\n\n\n<p>\u53c8\u662f\u6211\u7b2c\u4e00\u6b21\u89c1\u7684\u51fd\u6570\u3002\u53ef\u4ee5\u7406\u89e3\u5c06\u540c\u4e00\u5217\u7684\u4e0d\u540c\u884c\uff0c\u5408\u5e76\u5230\u4e00\u4e2a\u5b57\u7b26\u4e32\u4e2d\uff0c\u5e76\u5c06SEPARATOR str_val\u4e2d\u7684str_val\u4f5c\u4e3a\u5206\u9694\u7b26\uff0c\u9ed8\u8ba4\u7684\u8bdd\u5c31\u662f\u9017\u53f7&#8221;,&#8221;\u4f5c\u4e3a\u5206\u9694\u7b26\u3002\u800cORDER BY\u5982\u679c\u4e0d\u6307\u660e\u662fDESC\u7684\u8bdd\uff0c<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u9ed8\u8ba4\u4e3aASC\u5347\u5e8f\u6392\u5217<\/mark>\u3002<\/p>\n\n\n\n<p>\u5f53\u7136\u6700\u540e\u8981\u6839\u636esell_date\u8fdb\u884c\u5206\u7ec4\uff0c\u6240\u4ee5\u8fd8\u8981\u52a0\u4e0aGROUP BY.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\r\nSELECT sell_date,\r\nCOUNT(DISTINCT product) AS num_sold,\r\nGROUP_CONCAT(\r\n  DISTINCT product\r\n  ORDER BY product\r\n)\r\nAS products\r\nFROM Activities\r\nGROUP BY sell_date<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1aGROUP_CONCAT<\/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\/2267"}],"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=2267"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2267\/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=2267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=2267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=2267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}