{"id":4825,"date":"2023-11-11T10:50:39","date_gmt":"2023-11-11T02:50:39","guid":{"rendered":"https:\/\/white-night.club\/?p=4825"},"modified":"2023-11-11T11:25:37","modified_gmt":"2023-11-11T03:25:37","slug":"ad144","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/11\/11\/ad144\/","title":{"rendered":"262.\u00a0\u884c\u7a0b\u548c\u7528\u6237"},"content":{"rendered":"\n<p>\u8868\uff1a<code>Trips<\/code>+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+ | Column Name | Type | +&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+ | id | int | | client_id | int | | driver_id | int | | city_id | int | | status | enum | | request_at | date | +&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+ id \u662f\u8fd9\u5f20\u8868\u7684\u4e3b\u952e\uff08\u5177\u6709\u552f\u4e00\u503c\u7684\u5217\uff09\u3002 \u8fd9\u5f20\u8868\u4e2d\u5b58\u6240\u6709\u51fa\u79df\u8f66\u7684\u884c\u7a0b\u4fe1\u606f\u3002\u6bcf\u6bb5\u884c\u7a0b\u6709\u552f\u4e00 id \uff0c\u5176\u4e2d client_id \u548c driver_id \u662f Users \u8868\u4e2d users_id \u7684\u5916\u952e\u3002 status \u662f\u4e00\u4e2a\u8868\u793a\u884c\u7a0b\u72b6\u6001\u7684\u679a\u4e3e\u7c7b\u578b\uff0c\u679a\u4e3e\u6210\u5458\u4e3a(\u2018completed\u2019, \u2018cancelled_by_driver\u2019, \u2018cancelled_by_client\u2019) \u3002<\/p>\n\n\n\n<p>\u8868\uff1a<code>Users<\/code>+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+ | Column Name | Type | +&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+ | users_id | int | | banned | enum | | role | enum | +&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+ users_id \u662f\u8fd9\u5f20\u8868\u7684\u4e3b\u952e\uff08\u5177\u6709\u552f\u4e00\u503c\u7684\u5217\uff09\u3002 \u8fd9\u5f20\u8868\u4e2d\u5b58\u6240\u6709\u7528\u6237\uff0c\u6bcf\u4e2a\u7528\u6237\u90fd\u6709\u4e00\u4e2a\u552f\u4e00\u7684 users_id \uff0crole \u662f\u4e00\u4e2a\u8868\u793a\u7528\u6237\u8eab\u4efd\u7684\u679a\u4e3e\u7c7b\u578b\uff0c\u679a\u4e3e\u6210\u5458\u4e3a (\u2018client\u2019, \u2018driver\u2019, \u2018partner\u2019) \u3002 banned \u662f\u4e00\u4e2a\u8868\u793a\u7528\u6237\u662f\u5426\u88ab\u7981\u6b62\u7684\u679a\u4e3e\u7c7b\u578b\uff0c\u679a\u4e3e\u6210\u5458\u4e3a (\u2018Yes\u2019, \u2018No\u2019) \u3002<\/p>\n\n\n\n<p><strong>\u53d6\u6d88\u7387<\/strong>&nbsp;\u7684\u8ba1\u7b97\u65b9\u5f0f\u5982\u4e0b\uff1a(\u88ab\u53f8\u673a\u6216\u4e58\u5ba2\u53d6\u6d88\u7684\u975e\u7981\u6b62\u7528\u6237\u751f\u6210\u7684\u8ba2\u5355\u6570\u91cf) \/ (\u975e\u7981\u6b62\u7528\u6237\u751f\u6210\u7684\u8ba2\u5355\u603b\u6570)\u3002<\/p>\n\n\n\n<p>\u7f16\u5199\u89e3\u51b3\u65b9\u6848\u627e\u51fa&nbsp;<code>\"2013-10-01\"<\/code><strong>&nbsp;<\/strong>\u81f3&nbsp;<code>\"2013-10-03\"<\/code><strong>&nbsp;<\/strong>\u671f\u95f4\u975e\u7981\u6b62\u7528\u6237\uff08<strong>\u4e58\u5ba2\u548c\u53f8\u673a\u90fd\u5fc5\u987b\u672a\u88ab\u7981\u6b62<\/strong>\uff09\u7684\u53d6\u6d88\u7387\u3002\u975e\u7981\u6b62\u7528\u6237\u5373 banned \u4e3a No \u7684\u7528\u6237\uff0c\u7981\u6b62\u7528\u6237\u5373 banned \u4e3a Yes \u7684\u7528\u6237\u3002\u5176\u4e2d\u53d6\u6d88\u7387&nbsp;<code>Cancellation Rate<\/code>&nbsp;\u9700\u8981\u56db\u820d\u4e94\u5165\u4fdd\u7559&nbsp;<strong>\u4e24\u4f4d\u5c0f\u6570<\/strong>&nbsp;\u3002<\/p>\n\n\n\n<p>\u8fd4\u56de\u7ed3\u679c\u8868\u4e2d\u7684\u6570\u636e&nbsp;<strong>\u65e0\u987a\u5e8f\u8981\u6c42<\/strong>&nbsp;\u3002<\/p>\n\n\n\n<p>\u7ed3\u679c\u683c\u5f0f\u5982\u4e0b\u4f8b\u6240\u793a\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><strong>\u8f93\u5165\uff1a<\/strong> Trips \u8868\uff1a +&#8212;-+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;+ | id | client_id | driver_id | city_id | status | request_at | +&#8212;-+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;+ | 1 | 1 | 10 | 1 | completed | 2013-10-01 | | 2 | 2 | 11 | 1 | cancelled_by_driver | 2013-10-01 | | 3 | 3 | 12 | 6 | completed | 2013-10-01 | | 4 | 4 | 13 | 6 | cancelled_by_client | 2013-10-01 | | 5 | 1 | 10 | 1 | completed | 2013-10-02 | | 6 | 2 | 11 | 6 | completed | 2013-10-02 | | 7 | 3 | 12 | 6 | completed | 2013-10-02 | | 8 | 2 | 12 | 12 | completed | 2013-10-03 | | 9 | 3 | 10 | 12 | completed | 2013-10-03 | | 10 | 4 | 13 | 12 | cancelled_by_driver | 2013-10-03 | +&#8212;-+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;+ Users \u8868\uff1a +&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8211;+ | users_id | banned | role | +&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8211;+ | 1 | No | client | | 2 | Yes | client | | 3 | No | client | | 4 | No | client | | 10 | No | driver | | 11 | No | driver | | 12 | No | driver | | 13 | No | driver | +&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8211;+ <strong>\u8f93\u51fa\uff1a<\/strong> +&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+ | Day | Cancellation Rate | +&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+ | 2013-10-01 | 0.33 | | 2013-10-02 | 0.00 | | 2013-10-03 | 0.50 | +&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+ <strong>\u89e3\u91ca\uff1a<\/strong> 2013-10-01\uff1a &#8211; \u5171\u6709 4 \u6761\u8bf7\u6c42\uff0c\u5176\u4e2d 2 \u6761\u53d6\u6d88\u3002 &#8211; \u7136\u800c\uff0cid=2 \u7684\u8bf7\u6c42\u662f\u7531\u7981\u6b62\u7528\u6237\uff08user_id=2\uff09\u53d1\u51fa\u7684\uff0c\u6240\u4ee5\u8ba1\u7b97\u65f6\u5e94\u5f53\u5ffd\u7565\u5b83\u3002 &#8211; \u56e0\u6b64\uff0c\u603b\u5171\u6709 3 \u6761\u975e\u7981\u6b62\u8bf7\u6c42\u53c2\u4e0e\u8ba1\u7b97\uff0c\u5176\u4e2d 1 \u6761\u53d6\u6d88\u3002 &#8211; \u53d6\u6d88\u7387\u4e3a (1 \/ 3) = 0.33 2013-10-02\uff1a &#8211; \u5171\u6709 3 \u6761\u8bf7\u6c42\uff0c\u5176\u4e2d 0 \u6761\u53d6\u6d88\u3002 &#8211; \u7136\u800c\uff0cid=6 \u7684\u8bf7\u6c42\u662f\u7531\u7981\u6b62\u7528\u6237\u53d1\u51fa\u7684\uff0c\u6240\u4ee5\u8ba1\u7b97\u65f6\u5e94\u5f53\u5ffd\u7565\u5b83\u3002 &#8211; \u56e0\u6b64\uff0c\u603b\u5171\u6709 2 \u6761\u975e\u7981\u6b62\u8bf7\u6c42\u53c2\u4e0e\u8ba1\u7b97\uff0c\u5176\u4e2d 0 \u6761\u53d6\u6d88\u3002 &#8211; \u53d6\u6d88\u7387\u4e3a (0 \/ 2) = 0.00 2013-10-03\uff1a &#8211; \u5171\u6709 3 \u6761\u8bf7\u6c42\uff0c\u5176\u4e2d 1 \u6761\u53d6\u6d88\u3002 &#8211; \u7136\u800c\uff0cid=8 \u7684\u8bf7\u6c42\u662f\u7531\u7981\u6b62\u7528\u6237\u53d1\u51fa\u7684\uff0c\u6240\u4ee5\u8ba1\u7b97\u65f6\u5e94\u5f53\u5ffd\u7565\u5b83\u3002 &#8211; \u56e0\u6b64\uff0c\u603b\u5171\u6709 2 \u6761\u975e\u7981\u6b62\u8bf7\u6c42\u53c2\u4e0e\u8ba1\u7b97\uff0c\u5176\u4e2d 1 \u6761\u53d6\u6d88\u3002 &#8211; \u53d6\u6d88\u7387\u4e3a (1 \/ 2) = 0.50<\/p>\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 has-link-color wp-elements-b15925b27890b703bcb7eec1ec7d4404\">\n<p>\u89e3\u9898\u601d\u8def<\/p>\n<cite><em>JOIN+\u6d3e\u751f\u8868<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u975e\u5e38\u597d\u7684\u9898\uff0c\u4f7f\u6211\u5927\u8111\u65cb\u8f6c\u534a\u5c0f\u65f6\u3002<\/p>\n\n\n\n<p>\u6211\u7684\u601d\u8def\u8fd8\u662f\u633a\u66b4\u529b\u7684\u3002\u76f4\u63a5\u5148\u7b5b\u51fa\u6ca1\u88abbanned\u7684\u7528\u6237\u548c\u53f8\u673a\uff0c\u518d\u6309\u65e5\u671f\u5206\u7ec4\uff0c\u6700\u540e\u518d\u8fd0\u7b97\u3002<\/p>\n\n\n\n<p>\u4e00\u5f00\u59cb\u7528\u4e86LEFT JOIN\uff0c\u4f46\u662f\u7b2c11\u4e2a\u6837\u4f8b\u4e00\u76f4\u8fc7\u4e0d\u53bb\u3002\u540e\u9762\u53d1\u73b0\u5982\u679cB\u8868\u4e3a\u7a7a\u3001A\u8868\u4e0d\u4e3a\u7a7a\uff0c\u90a3\u4e48B\u8868\u4ecd\u7136\u4f1aJOIN\u5230A\u8868\u4e2d\u3002\u5bfc\u81f4\u6700\u540eCOUNT\u7684\u7ed3\u679c\u4e0d\u662f1\u5c31\u662f0\u3002<\/p>\n\n\n\n<p>\u90a3\u4ec0\u4e48\u60c5\u51b5\u4e0bB\u8868\u4e3a\u7a7a\u5462\uff1f\u5f53\u6240\u6709driver\u90fd\u88abbanned\u7684\u65f6\u5019\u5c31\u4f1a\u4e3a\u7a7a\u3002\u90a3\u4e48\u6b64\u65f6Cancellation Rate\u5df2\u7ecf\u6ca1\u610f\u4e49\u4e86\u2014\u2014\u6240\u6709\u7ed3\u679c\u96c6\u90fd\u5e94\u8be5\u88ab\u7b5b\u9009\u6389\u3002\u6211\u622a\u4e86\u4e24\u5f20\u56fe\u65b9\u4fbf\u7406\u89e3\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"405\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/11\/d0ad4214aede11fb7ca9ec4fd003964-1024x405.png\" alt=\"\" class=\"wp-image-4830\" style=\"border-style:none;border-width:0px;border-radius:0px;width:840px;height:auto\" srcset=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/11\/d0ad4214aede11fb7ca9ec4fd003964-1024x405.png 1024w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/11\/d0ad4214aede11fb7ca9ec4fd003964-300x119.png 300w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/11\/d0ad4214aede11fb7ca9ec4fd003964-768x303.png 768w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/11\/d0ad4214aede11fb7ca9ec4fd003964.png 1182w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"418\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/11\/48daedfe43b23b6332e944e67247e0b-1024x418.png\" alt=\"\" class=\"wp-image-4832\" style=\"border-style:none;border-width:0px;border-radius:0px\" srcset=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/11\/48daedfe43b23b6332e944e67247e0b-1024x418.png 1024w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/11\/48daedfe43b23b6332e944e67247e0b-300x122.png 300w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/11\/48daedfe43b23b6332e944e67247e0b-768x314.png 768w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/11\/48daedfe43b23b6332e944e67247e0b.png 1112w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u5177\u4f53\u7684SQL\u8bed\u53e5\u5982\u4e0b\uff0c\u8bf4\u5b9e\u8bdd\u770b\u8d77\u6765\u5199\u7684\u662f\u6709\u70b9\u590d\u6742\u4e86\uff0c\u4e0d\u7ba1\u8fd0\u884c\u65f6\u95f4\u51fa\u4e4e\u6211\u610f\u6599\u7684\u77ed\uff0c\u6709\u70b9\u6ca1\u60f3\u5230\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"937\" height=\"345\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/11\/177dd284f6c7dba48ed8c3e45615617.png\" alt=\"\" class=\"wp-image-4833\" style=\"border-style:none;border-width:0px;border-radius:0px\" srcset=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/11\/177dd284f6c7dba48ed8c3e45615617.png 937w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/11\/177dd284f6c7dba48ed8c3e45615617-300x110.png 300w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/11\/177dd284f6c7dba48ed8c3e45615617-768x283.png 768w\" sizes=\"(max-width: 937px) 100vw, 937px\" \/><\/figure>\n\n\n\n<p>\u4e5f\u53ef\u80fd\u7ed9\u7684\u6570\u636e\u96c6\u90fd\u6bd4\u8f83\u5c0f\u5427\u3002\u5982\u679c\u771f\u7684\u8981\u4f18\u5316\u7684\u8bdd\u8981\u4eceA\uff0cB\u8868\u8fd9\u4e24\u4e2a\u5730\u65b9\u4e0b\u624b\uff0c\u4e24\u4e2a\u6d3e\u751f\u8868\u91cc\u9762\u7684LEFT JOIN\u7b97\u91cd\u590d\u6b65\u9aa4\u4e86\u3002\u4e0d\u8fc7\u6211\u6ca1\u60f3\u5230\u6709\u4ec0\u4e48\u5f88\u597d\u7684\u65b9\u6cd5\u4f18\u5316\u8fd9\u5757\uff0c\u7b49\u540e\u7eed\u5b66\u4e60\u770b\u770b\u5427\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\r\nSELECT A.request_at AS Day\r\n,ROUND((COUNT(IF(A.status='cancelled_by_client',1,NULL))\r\n+COUNT(IF(B.status='cancelled_by_driver',1,NULL)) \r\n)\/COUNT(A.id),2)AS 'Cancellation Rate'\r\nFROM(\r\n  SELECT id,request_at,client_id,banned,status\r\n  FROM Trips\r\n  LEFT JOIN Users\r\n  ON client_id=users_id\r\n  WHERE banned='NO'\r\n)A\r\nJOIN(\r\n  SELECT id,request_at,driver_id,banned,status\r\n  FROM Trips AS B\r\n  LEFT JOIN Users AS C\r\n  ON driver_id=users_id\r\n  WHERE banned='NO'\r\n)B\r\nON A.id=B.id\r\nWHERE A.request_at&lt;='2013-10-03'\r\nAND A.request_at>='2013-10-01'\r\nGROUP BY A.request_at<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\u6d3e\u751f\u8868<\/p>\n","protected":false},"author":1,"featured_media":4830,"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\/4825"}],"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=4825"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/4825\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/4830"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=4825"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=4825"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=4825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}