{"id":3211,"date":"2023-10-22T11:16:04","date_gmt":"2023-10-22T03:16:04","guid":{"rendered":"https:\/\/white-night.club\/?p=3211"},"modified":"2023-11-09T11:07:47","modified_gmt":"2023-11-09T03:07:47","slug":"ad84","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/22\/ad84\/","title":{"rendered":"1581.\u00a0\u8fdb\u5e97\u5374\u672a\u8fdb\u884c\u8fc7\u4ea4\u6613\u7684\u987e\u5ba2"},"content":{"rendered":"\n<p>\u8868\uff1a<code>Visits<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+-------------+---------+\n| Column Name | Type    |\n+-------------+---------+\n| visit_id    | int     |\n| customer_id | int     |\n+-------------+---------+\nvisit_id \u662f\u8be5\u8868\u4e2d\u5177\u6709\u552f\u4e00\u503c\u7684\u5217\u3002\n\u8be5\u8868\u5305\u542b\u6709\u5173\u5149\u4e34\u8fc7\u8d2d\u7269\u4e2d\u5fc3\u7684\u987e\u5ba2\u7684\u4fe1\u606f\u3002\n<\/pre>\n\n\n\n<p>\u8868\uff1a<code>Transactions<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+----------------+---------+\n| Column Name    | Type    |\n+----------------+---------+\n| transaction_id | int     |\n| visit_id       | int     |\n| amount         | int     |\n+----------------+---------+\ntransaction_id \u662f\u8be5\u8868\u4e2d\u5177\u6709\u552f\u4e00\u503c\u7684\u5217\u3002\n\u6b64\u8868\u5305\u542b visit_id \u671f\u95f4\u8fdb\u884c\u7684\u4ea4\u6613\u7684\u4fe1\u606f\u3002\n<\/pre>\n\n\n\n<p>\u6709\u4e00\u4e9b\u987e\u5ba2\u53ef\u80fd\u5149\u987e\u4e86\u8d2d\u7269\u4e2d\u5fc3\u4f46\u6ca1\u6709\u8fdb\u884c\u4ea4\u6613\u3002\u8bf7\u4f60\u7f16\u5199\u4e00\u4e2a\u89e3\u51b3\u65b9\u6848\uff0c\u6765\u67e5\u627e\u8fd9\u4e9b\u987e\u5ba2\u7684 ID \uff0c\u4ee5\u53ca\u4ed6\u4eec\u53ea\u5149\u987e\u4e0d\u4ea4\u6613\u7684\u6b21\u6570\u3002<\/p>\n\n\n\n<p>\u8fd4\u56de\u4ee5&nbsp;<strong>\u4efb\u4f55\u987a\u5e8f<\/strong>&nbsp;\u6392\u5e8f\u7684\u7ed3\u679c\u8868\u3002<\/p>\n\n\n\n<p>\u8fd4\u56de\u7ed3\u679c\u683c\u5f0f\u5982\u4e0b\u4f8b\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\"><code><strong>\u8f93\u5165:<\/strong>\nVisits<\/code>\n+----------+-------------+\n| visit_id | customer_id |\n+----------+-------------+\n| 1        | 23          |\n| 2        | 9           |\n| 4        | 30          |\n| 5        | 54          |\n| 6        | 96          |\n| 7        | 54          |\n| 8        | 54          |\n+----------+-------------+\n<code>Transactions<\/code>\n+----------------+----------+--------+\n| transaction_id | visit_id | amount |\n+----------------+----------+--------+\n| 2              | 5        | 310    |\n| 3              | 5        | 300    |\n| 9              | 5        | 200    |\n| 12             | 1        | 910    |\n| 13             | 2        | 970    |\n+----------------+----------+--------+\n<strong>\u8f93\u51fa:<\/strong>\n+-------------+----------------+\n| customer_id | count_no_trans |\n+-------------+----------------+\n| 54          | 2              |\n| 30          | 1              |\n| 96          | 1              |\n+-------------+----------------+\n<strong>\u89e3\u91ca:<\/strong>\nID = 23 \u7684\u987e\u5ba2\u66fe\u7ecf\u901b\u8fc7\u4e00\u6b21\u8d2d\u7269\u4e2d\u5fc3\uff0c\u5e76\u5728 ID = 12 \u7684\u8bbf\u95ee\u671f\u95f4\u8fdb\u884c\u4e86\u4e00\u7b14\u4ea4\u6613\u3002\nID = 9 \u7684\u987e\u5ba2\u66fe\u7ecf\u901b\u8fc7\u4e00\u6b21\u8d2d\u7269\u4e2d\u5fc3\uff0c\u5e76\u5728 ID = 13 \u7684\u8bbf\u95ee\u671f\u95f4\u8fdb\u884c\u4e86\u4e00\u7b14\u4ea4\u6613\u3002\nID = 30 \u7684\u987e\u5ba2\u66fe\u7ecf\u53bb\u8fc7\u8d2d\u7269\u4e2d\u5fc3\uff0c\u5e76\u4e14\u6ca1\u6709\u8fdb\u884c\u4efb\u4f55\u4ea4\u6613\u3002\nID = 54 \u7684\u987e\u5ba2\u4e09\u5ea6\u9020\u8bbf\u4e86\u8d2d\u7269\u4e2d\u5fc3\u3002\u5728 2 \u6b21\u8bbf\u95ee\u4e2d\uff0c\u4ed6\u4eec\u6ca1\u6709\u8fdb\u884c\u4efb\u4f55\u4ea4\u6613\uff0c\u5728 1 \u6b21\u8bbf\u95ee\u4e2d\uff0c\u4ed6\u4eec\u8fdb\u884c\u4e86 3 \u6b21\u4ea4\u6613\u3002\nID = 96 \u7684\u987e\u5ba2\u66fe\u7ecf\u53bb\u8fc7\u8d2d\u7269\u4e2d\u5fc3\uff0c\u5e76\u4e14\u6ca1\u6709\u8fdb\u884c\u4efb\u4f55\u4ea4\u6613\u3002\n\u5982\u6211\u4eec\u6240\u89c1\uff0cID \u4e3a 30 \u548c 96 \u7684\u987e\u5ba2\u4e00\u6b21\u6ca1\u6709\u8fdb\u884c\u4efb\u4f55\u4ea4\u6613\u5c31\u53bb\u4e86\u8d2d\u7269\u4e2d\u5fc3\u3002\u987e\u5ba2 54 \u4e5f\u4e24\u6b21\u8bbf\u95ee\u4e86\u8d2d\u7269\u4e2d\u5fc3\u5e76\u4e14\u6ca1\u6709\u8fdb\u884c\u4efb\u4f55\u4ea4\u6613\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>\u76f8\u5173\u5b50\u67e5\u8be2<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u867d\u7136\u8bf4\u662f\u7b80\u5355\u9898\uff0c\u4f46\u8fd8\u662f\u601d\u8003\u4e86\u4e00\u4e0b\u624d\u5199\u51fa\u6765\uff0c\u53cd\u601d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\r\nSELECT A.customer_id,COUNT(A.customer_id) AS count_no_trans\r\nFROM Visits AS A\r\nWHERE NOT EXISTS(\r\n  SELECT B.* FROM Transactions AS B\r\n  WHERE A.visit_id=B.visit_id\r\n) \r\nGROUP BY customer_id\r\nORDER BY count_no_trans DESC<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\u76f8\u5173\u5b50\u67e5\u8be2<\/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\/3211"}],"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=3211"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/3211\/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=3211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=3211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=3211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}