{"id":2556,"date":"2023-10-14T11:59:52","date_gmt":"2023-10-14T03:59:52","guid":{"rendered":"https:\/\/white-night.club\/?p=2556"},"modified":"2023-11-09T11:07:50","modified_gmt":"2023-11-09T03:07:50","slug":"ad48","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/14\/ad48\/","title":{"rendered":"511.\u00a0\u6e38\u620f\u73a9\u6cd5\u5206\u6790 I"},"content":{"rendered":"\n<p>\u6d3b\u52a8\u8868&nbsp;<code>Activity<\/code>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+--------------+---------+\n| Column Name  | Type    |\n+--------------+---------+\n| player_id    | int     |\n| device_id    | int     |\n| event_date   | date    |\n| games_played | int     |\n+--------------+---------+\n\u5728 SQL \u4e2d\uff0c\u8868\u7684\u4e3b\u952e\u662f (player_id, event_date)\u3002\n\u8fd9\u5f20\u8868\u5c55\u793a\u4e86\u4e00\u4e9b\u6e38\u620f\u73a9\u5bb6\u5728\u6e38\u620f\u5e73\u53f0\u4e0a\u7684\u884c\u4e3a\u6d3b\u52a8\u3002\n\u6bcf\u884c\u6570\u636e\u8bb0\u5f55\u4e86\u4e00\u540d\u73a9\u5bb6\u5728\u9000\u51fa\u5e73\u53f0\u4e4b\u524d\uff0c\u5f53\u5929\u4f7f\u7528\u540c\u4e00\u53f0\u8bbe\u5907\u767b\u5f55\u5e73\u53f0\u540e\u6253\u5f00\u7684\u6e38\u620f\u7684\u6570\u76ee\uff08\u53ef\u80fd\u662f 0 \u4e2a\uff09\u3002\n<\/pre>\n\n\n\n<p>\u67e5\u8be2\u6bcf\u4f4d\u73a9\u5bb6&nbsp;<strong>\u7b2c\u4e00\u6b21\u767b\u9646\u5e73\u53f0\u7684\u65e5\u671f<\/strong>\u3002<\/p>\n\n\n\n<p>\u67e5\u8be2\u7ed3\u679c\u7684\u683c\u5f0f\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Activity \u8868\uff1a\n+-----------+-----------+------------+--------------+\n| player_id | device_id | event_date | games_played |\n+-----------+-----------+------------+--------------+\n| 1         | 2         | 2016-03-01 | 5            |\n| 1         | 2         | 2016-05-02 | 6            |\n| 2         | 3         | 2017-06-25 | 1            |\n| 3         | 1         | 2016-03-02 | 0            |\n| 3         | 4         | 2018-07-03 | 5            |\n+-----------+-----------+------------+--------------+\n\nResult \u8868\uff1a\n+-----------+-------------+\n| player_id | first_login |\n+-----------+-------------+\n| 1         | 2016-03-01  |\n| 2         | 2017-06-25  |\n| 3         | 2016-03-02  |\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\u7684\u7528\u6cd5<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u4e3b\u8981\u662f\u8bb0\u5f55\u4e0bGROUP BY\u7684\u7528\u6cd5\u3002GROUP BY\u4e3b\u8981\u662f\u548c\u805a\u96c6\u51fd\u6570\uff08MIN\uff0cMAX\uff0cCOUNT&#8230;)\u8fdb\u884c\u642d\u914d\uff0c\u5e76\u6839\u636e\u67d0\u4e00\u5217\u7684\u6570\u636e\u5bf9\u805a\u96c6\u51fd\u6570\u7684\u7ed3\u679c\u96c6\u8fdb\u884c\u5206\u7ec4\u3002<\/p>\n\n\n\n<p>\u6bd4\u5982\u8fd9\u9898\u662f\u8981\u627e\u67d0\u4e2aid\u5bf9\u5e94\u7684event_date\u7684\u6700\u5c0f\u503c\uff0c\u90a3\u5c31\u662f\u6309player_id\u5bf9\u6bcf\u4e2aid\u7684event_date\u8fdb\u884c\u5206\u7ec4\uff0c\u7136\u540e\u53d6\u5176\u4e2d\u7684\u6700\u5c0f\u503c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\r\nSELECT player_id,MIN(event_date) AS first_login\r\nFROM Activity\r\nGROUP BY player_id<\/code><\/pre>\n\n\n\n<p><\/p>\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\/2556"}],"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=2556"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2556\/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=2556"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=2556"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=2556"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}