{"id":3354,"date":"2023-10-26T08:50:17","date_gmt":"2023-10-26T00:50:17","guid":{"rendered":"https:\/\/white-night.club\/?p=3354"},"modified":"2023-11-09T11:07:46","modified_gmt":"2023-11-09T03:07:46","slug":"ad99","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/26\/ad99\/","title":{"rendered":"534.\u00a0\u6e38\u620f\u73a9\u6cd5\u5206\u6790 III"},"content":{"rendered":"\n<p>\u8868\uff1a<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\uff08player_id\uff0cevent_date\uff09\u662f\u6b64\u8868\u7684\u4e3b\u952e\uff08\u5177\u6709\u552f\u4e00\u503c\u7684\u5217\uff09\u3002\n\u8fd9\u5f20\u8868\u663e\u793a\u4e86\u67d0\u4e9b\u6e38\u620f\u7684\u73a9\u5bb6\u7684\u6d3b\u52a8\u60c5\u51b5\u3002\n\u6bcf\u4e00\u884c\u662f\u4e00\u4e2a\u73a9\u5bb6\u7684\u8bb0\u5f55\uff0c\u4ed6\u5728\u67d0\u4e00\u5929\u4f7f\u7528\u67d0\u4e2a\u8bbe\u5907\u6ce8\u9500\u4e4b\u524d\u767b\u5f55\u5e76\u73a9\u4e86\u5f88\u591a\u6e38\u620f\uff08\u53ef\u80fd\u662f 0 \uff09\u3002\n<\/pre>\n\n\n\n<p>\u7f16\u5199\u4e00\u4e2a\u89e3\u51b3\u65b9\u6848\uff0c\u540c\u65f6\u62a5\u544a\u6bcf\u7ec4\u73a9\u5bb6\u548c\u65e5\u671f\uff0c\u4ee5\u53ca\u73a9\u5bb6\u5230&nbsp;<strong>\u76ee\u524d\u4e3a\u6b62<\/strong>&nbsp;\u73a9\u4e86\u591a\u5c11\u6e38\u620f\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u73a9\u5bb6\u5728\u8be5\u65e5\u671f\u4e4b\u524d\u6240\u73a9\u7684\u6e38\u620f\u603b\u6570\u3002\u8be6\u7ec6\u60c5\u51b5\u8bf7\u67e5\u770b\u793a\u4f8b\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>\u7ed3\u679c\u683c\u5f0f\u5982\u4e0b\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\"><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| 1         | 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 | event_date | games_played_so_far |\n+-----------+------------+---------------------+\n| 1         | 2016-03-01 | 5                   |\n| 1         | 2016-05-02 | 11                  |\n| 1         | 2017-06-25 | 12                  |\n| 3         | 2016-03-02 | 0                   |\n| 3         | 2018-07-03 | 5                   |\n+-----------+------------+---------------------+\n<strong>\u89e3\u91ca\uff1a<\/strong>\n\u5bf9\u4e8e ID \u4e3a 1 \u7684\u73a9\u5bb6\uff0c2016-05-02 \u5171\u73a9\u4e86 5+6=11 \u4e2a\u6e38\u620f\uff0c2017-06-25 \u5171\u73a9\u4e86 5+6+1=12 \u4e2a\u6e38\u620f\u3002\n\u5bf9\u4e8e ID \u4e3a 3 \u7684\u73a9\u5bb6\uff0c2018-07-03 \u5171\u73a9\u4e86 0+5=5 \u4e2a\u6e38\u620f\u3002\n\u8bf7\u6ce8\u610f\uff0c\u5bf9\u4e8e\u6bcf\u4e2a\u73a9\u5bb6\uff0c\u6211\u4eec\u53ea\u5173\u5fc3\u73a9\u5bb6\u7684\u767b\u5f55\u65e5\u671f\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>\u7a97\u53e3\u51fd\u6570SUM<\/em><\/cite><\/blockquote>\n\n\n\n<p>sum\u4e5f\u53ef\u4ee5\u5f53\u7a97\u53e3\u51fd\u6570\u7528\u554a\uff0c\u5b66\u5230\u4e86\u3002<\/p>\n\n\n\n<p>SUM\u5bf9ove( )\u91cc\u7684\u5185\u5bb9\u6c42\u548c\uff0cover\u91cc\u9762\u662f\u6309id\u5206\u7ec4\u7684\u65e5\u671f\uff0c\u8868\u793a\u4ece\u5f53\u524d\u884c\u4e00\u76f4\u5f80\u524dSUM\u76f4\u5230\u7b2c\u4e00\u884c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\r\nSELECT player_id,event_date,\r\nSUM(games_played)over(partition by player_id order by event_date ASC) AS games_played_so_far\r\nFROM Activity\r<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\u7a97\u53e3\u51fd\u6570SUM<\/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\/3354"}],"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=3354"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/3354\/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=3354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=3354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=3354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}