{"id":2594,"date":"2023-10-15T11:07:29","date_gmt":"2023-10-15T03:07:29","guid":{"rendered":"https:\/\/white-night.club\/?p=2594"},"modified":"2023-11-09T11:07:49","modified_gmt":"2023-11-09T03:07:49","slug":"ad54","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/15\/ad54\/","title":{"rendered":"512.\u00a0\u6e38\u620f\u73a9\u6cd5\u5206\u6790 II"},"content":{"rendered":"\n<p>Table:&nbsp;<code>Activity<\/code><\/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(player_id, event_date) \u662f\u8fd9\u4e2a\u8868\u7684\u4e24\u4e2a\u4e3b\u952e(\u5177\u6709\u552f\u4e00\u503c\u7684\u5217\u7684\u7ec4\u5408)\n\u8fd9\u4e2a\u8868\u663e\u793a\u7684\u662f\u67d0\u4e9b\u6e38\u620f\u73a9\u5bb6\u7684\u6e38\u620f\u6d3b\u52a8\u60c5\u51b5\n\u6bcf\u4e00\u884c\u662f\u5728\u67d0\u5929\u4f7f\u7528\u67d0\u4e2a\u8bbe\u5907\u767b\u51fa\u4e4b\u524d\u767b\u5f55\u5e76\u73a9\u591a\u4e2a\u6e38\u620f\uff08\u53ef\u80fd\u4e3a0\uff09\u7684\u73a9\u5bb6\u7684\u8bb0\u5f55\n<\/pre>\n\n\n\n<p>\u8bf7\u7f16\u5199\u89e3\u51b3\u65b9\u6848\uff0c\u63cf\u8ff0\u6bcf\u4e00\u4e2a\u73a9\u5bb6\u9996\u6b21\u767b\u9646\u7684\u8bbe\u5907\u540d\u79f0<\/p>\n\n\n\n<p>\u8fd4\u56de\u7ed3\u679c\u683c\u5f0f\u5982\u4ee5\u4e0b\u793a\u4f8b\uff1a<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>\nActivity table:\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<strong>\u8f93\u51fa\uff1a<\/strong>\n+-----------+-----------+\n| player_id | device_id |\n+-----------+-----------+\n| 1         | 2         |\n| 2         | 3         |\n| 3         | 1         |\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>WHERE IN<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u719f\u6089\u4e00\u4e0bWHERE IN\u7684\u7528\u6cd5\u3002\u4e00\u76f4\u4ee5\u4e3aWHERE IN\u540e\u9762\u8ddf\u7740\u7684\u662f\u5177\u4f53\u7684\u67d0\u4e2a\u6570\u636e\uff0c\u4f46\u662fIN\u540e\u9762\u4e5f\u53ef\u4ee5\u8ddf\u7740SELECT\u7684\u7ed3\u679c\u96c6\u3002<\/p>\n\n\n\n<p class=\"has-text-align-center\"><em><strong>WHERE \uff08col_1 col_2,&#8230;) IN (SELECT col_1,col_3,&#8230; FROM&#8230;)<\/strong><\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\r\nSELECT A.player_id,A.device_id\r\nFROM Activity AS A\r\nWHERE (A.player_id,A.event_date) IN(\r\n    SELECT B.player_id,MIN(B.event_date)\r\n    FROM Activity AS B\r\n    GROUP BY player_id\r\n)\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1aWHERE IN<\/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\/2594"}],"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=2594"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2594\/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=2594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=2594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=2594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}