{"id":4321,"date":"2023-11-08T09:57:05","date_gmt":"2023-11-08T01:57:05","guid":{"rendered":"https:\/\/white-night.club\/?p=4321"},"modified":"2023-11-09T11:07:42","modified_gmt":"2023-11-09T03:07:42","slug":"ad138","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/11\/08\/ad138\/","title":{"rendered":"1693.\u00a0\u6bcf\u5929\u7684\u9886\u5bfc\u548c\u5408\u4f19\u4eba"},"content":{"rendered":"\n<p>\u8868\uff1a<code>DailySales<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+-------------+---------+\n| Column Name | Type    |\n+-------------+---------+\n| date_id     | date    |\n| make_name   | varchar |\n| lead_id     | int     |\n| partner_id  | int     |\n+-------------+---------+\n\u8be5\u8868\u6ca1\u6709\u4e3b\u952e(\u5177\u6709\u552f\u4e00\u503c\u7684\u5217)\u3002\u5b83\u53ef\u80fd\u5305\u542b\u91cd\u590d\u9879\u3002\n\u8be5\u8868\u5305\u542b\u65e5\u671f\u3001\u4ea7\u54c1\u7684\u540d\u79f0\uff0c\u4ee5\u53ca\u552e\u7ed9\u7684\u9886\u5bfc\u548c\u5408\u4f19\u4eba\u7684\u7f16\u53f7\u3002\n\u540d\u79f0\u53ea\u5305\u542b\u5c0f\u5199\u82f1\u6587\u5b57\u6bcd\u3002<\/pre>\n\n\n\n<p>\u5bf9\u4e8e\u6bcf\u4e00\u4e2a&nbsp;<code>date_id<\/code>&nbsp;\u548c&nbsp;<code>make_name<\/code>\uff0c\u627e\u51fa&nbsp;<strong>\u4e0d\u540c&nbsp;<\/strong>\u7684&nbsp;<code>lead_id<\/code>&nbsp;\u4ee5\u53ca&nbsp;<strong>\u4e0d\u540c&nbsp;<\/strong>\u7684&nbsp;<code>partner_id<\/code>&nbsp;\u7684\u6570\u91cf\u3002<\/p>\n\n\n\n<p>\u6309&nbsp;<strong>\u4efb\u610f\u987a\u5e8f<\/strong>&nbsp;\u8fd4\u56de\u7ed3\u679c\u8868\u3002<\/p>\n\n\n\n<p>\u8fd4\u56de\u7ed3\u679c\u683c\u5f0f\u5982\u4e0b\u793a\u4f8b\u6240\u793a\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>\nDailySales \u8868\uff1a\n+-----------+-----------+---------+------------+\n| date_id   | make_name | lead_id | partner_id |\n+-----------+-----------+---------+------------+\n| 2020-12-8 | toyota    | 0       | 1          |\n| 2020-12-8 | toyota    | 1       | 0          |\n| 2020-12-8 | toyota    | 1       | 2          |\n| 2020-12-7 | toyota    | 0       | 2          |\n| 2020-12-7 | toyota    | 0       | 1          |\n| 2020-12-8 | honda     | 1       | 2          |\n| 2020-12-8 | honda     | 2       | 1          |\n| 2020-12-7 | honda     | 0       | 1          |\n| 2020-12-7 | honda     | 1       | 2          |\n| 2020-12-7 | honda     | 2       | 1          |\n+-----------+-----------+---------+------------+\n<strong>\u8f93\u51fa\uff1a<\/strong>\n+-----------+-----------+--------------+-----------------+\n| date_id   | make_name | unique_leads | unique_partners |\n+-----------+-----------+--------------+-----------------+\n| 2020-12-8 | toyota    | 2            | 3               |\n| 2020-12-7 | toyota    | 1            | 2               |\n| 2020-12-8 | honda     | 2            | 2               |\n| 2020-12-7 | honda     | 3            | 2               |\n+-----------+-----------+--------------+-----------------+\n<strong>\u89e3\u91ca\uff1a<\/strong>\n\u5728 2020-12-8\uff0c\u4e30\u7530\uff08toyota\uff09\u6709\u9886\u5bfc\u8005 = [0, 1] \u548c\u5408\u4f19\u4eba = [0, 1, 2] \uff0c\u540c\u65f6\u672c\u7530\uff08honda\uff09\u6709\u9886\u5bfc\u8005 = [1, 2] \u548c\u5408\u4f19\u4eba = [1, 2]\u3002\n\u5728 2020-12-7\uff0c\u4e30\u7530\uff08toyota\uff09\u6709\u9886\u5bfc\u8005 = [0] \u548c\u5408\u4f19\u4eba = [1, 2] \uff0c\u540c\u65f6\u672c\u7530\uff08honda\uff09\u6709\u9886\u5bfc\u8005 = [0, 1, 2] \u548c\u5408\u4f19\u4eba = [1, 2]\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>COUNT DISTINCT<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u6ca1\u770b\u61c2\u9898&#8230;\u770b\u6837\u4f8b\u624d\u770b\u61c2\uff0c\u8bf4\u767d\u4e86\u5c31\u662f\u7edf\u8ba1\u51fa\u73b0\u8fc7\u51e0\u4e2a\u9886\u5bfc\u8005\u548c\u5408\u4f19\u4eba\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\r\nSELECT date_id,make_name,\r\nCOUNT(DISTINCT lead_id) AS unique_leads,\r\nCOUNT(DISTINCT partner_id) AS unique_partners\r\nFROM DailySales\r\nGROUP BY date_id,make_name<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1aCOUNT DISTINCT<\/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\/4321"}],"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=4321"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/4321\/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=4321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=4321"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=4321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}