{"id":3327,"date":"2023-10-25T18:25:11","date_gmt":"2023-10-25T10:25:11","guid":{"rendered":"https:\/\/white-night.club\/?p=3327"},"modified":"2023-11-09T11:07:46","modified_gmt":"2023-11-09T03:07:46","slug":"ad97","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/25\/ad97\/","title":{"rendered":"2687.\u00a0\u81ea\u884c\u8f66\u7684\u6700\u540e\u4f7f\u7528\u65f6\u95f4"},"content":{"rendered":"\n<p>\u8868\uff1a<code>Bikes<\/code>&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+-------------+----------+ \n| \u5217\u540d        | \u7c7b\u578b     | \n+-------------+----------+ \n| ride_id     | int      | \n| bike_number | int      | \n| start_time  | datetime |\n| end_time    | datetime |\n+-------------+----------+\nride_id \u662f\u8be5\u8868\u7684\u4e3b\u952e\u3002\n\u6bcf\u884c\u5305\u542b\u4e00\u4e2a\u9a91\u884c\u4fe1\u606f\uff0c\u5305\u62ec ride_id\u3001\u81ea\u884c\u8f66\u7f16\u53f7\u3001\u9a91\u884c\u7684\u8d77\u59cb\u548c\u7ed3\u675f\u65f6\u95f4\u3002<\/pre>\n\n\n\n<p>\u7f16\u5199\u4e00\u4e2a\u89e3\u51b3\u65b9\u6848\uff0c\u627e\u51fa\u6bcf\u8f86\u81ea\u884c\u8f66&nbsp;<strong>\u6700\u8fd1\u4e00\u6b21\u88ab\u4f7f\u7528<\/strong>&nbsp;\u7684\u65f6\u95f4\u3002<\/p>\n\n\n\n<p>\u8fd4\u56de\u7ed3\u679c\u8868\u6309&nbsp;<strong>\u6700\u8fd1\u88ab\u4f7f\u7528<\/strong>&nbsp;\u7684\u81ea\u884c\u8f66\u8fdb\u884c\u6392\u5e8f\u3002<\/p>\n\n\n\n<p>\u8fd4\u56de\u7ed3\u679c\u7684\u683c\u5f0f\u5982\u4e0b\u6240\u793a\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\n<\/strong><code>Bikes<\/code> \u8868:\n+---------+-------------+---------------------+---------------------+ \n| ride_id | bike_number | start_time          | end_time            |  \n+---------+-------------+---------------------+---------------------+\n| 1       | W00576      | 2012-03-25 11:30:00 | 2012-03-25 12:40:00 |\n| 2       | W00300      | 2012-03-25 10:30:00 | 2012-03-25 10:50:00 |\n| 3       | W00455      | 2012-03-26 14:30:00 | 2012-03-26 17:40:00 |\n| 4       | W00455      | 2012-03-25 12:30:00 | 2012-03-25 13:40:00 |\n| 5       | W00576      | 2012-03-25 08:10:00 | 2012-03-25 09:10:00 |\n| 6       | W00576      | 2012-03-28 02:30:00 | 2012-03-28 02:50:00 |\n+---------+-------------+---------------------+---------------------+ \n<strong>\u8f93\u51fa\uff1a<\/strong>\n+-------------+---------------------+ \n| bike_number | end_time            |  \n+-------------+---------------------+\n| W00576      | 2012-03-28 02:50:00 |\n| W00455      | 2012-03-26 17:40:00 |\n| W00300      | 2012-03-25 10:50:00 |\n+-------------+---------------------+ \n<strong>\u89e3\u91ca\uff1a<\/strong>\n\u7f16\u53f7\u4e3a W00576 \u7684\u81ea\u884c\u8f66\u6709\u4e09\u6b21\u9a91\u884c\u8bb0\u5f55\uff0c\u5176\u4e2d\u6700\u8fd1\u7684\u9a91\u884c\u8bb0\u5f55\u662f ride_id \u4e3a 6\uff0c\u4e8e 2012-03-28 02:50:00\u7ed3\u675f\u3002\n\u7f16\u53f7\u4e3a W00300 \u7684\u81ea\u884c\u8f66\u53ea\u6709\u4e00\u6b21\u9a91\u884c\u8bb0\u5f55\uff0c\u6240\u4ee5\u6211\u4eec\u76f4\u63a5\u5728\u8f93\u51fa\u4e2d\u5305\u542b\u7ed3\u675f\u65f6\u95f4\u3002\n\u7f16\u53f7\u4e3a W00455 \u7684\u81ea\u884c\u8f66\u6709\u4e24\u6b21\u9a91\u884c\u8bb0\u5f55\uff0c\u5176\u4e2d\u6700\u8fd1\u7684\u9a91\u884c\u8bb0\u5f55\u662f ride_id \u4e3a 3\uff0c\u4e8e 2012-03-26 17:40:00\u7ed3\u675f\u3002\n\u6309\u7167\u6700\u8fd1\u4f7f\u7528\u7684\u81ea\u884c\u8f66\u987a\u5e8f\u8fd4\u56de\u8f93\u51fa\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>row_number()<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u8fd9\u9053\u9898\u5c31\u8981\u7528row_number\u4e86\uff0c\u56e0\u4e3a\u53ea\u9700\u8981<strong>\u4e00\u4e2a\u7b2c\u4e00<\/strong>\uff0c\u800c\u4e0d\u662f<strong>\u4e00\u7ec4\u7b2c\u4e00<\/strong>\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\r\nSELECT bike_number,end_time\r\nFROM (\r\n    SELECT *,row_number()over(partition by bike_number order by end_time DESC) AS rk\r\n    FROM Bikes\r\n) t\r\nWHERE rk=1<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\u7a97\u53e3\u51fd\u6570row_number<\/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\/3327"}],"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=3327"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/3327\/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=3327"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=3327"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=3327"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}