Try   HackMD

1693. Daily Leads and Partners

(資訊來自於leetcode 1693 Daily Leads and Partners)

每日線索和合作夥伴

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

編寫一個 SQL 查詢,對於每個date_idand make_name,返回不重複 lead_id和不重複 partner_id的數量。
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

解題方式:

SELECT date_id, make_name, count(distinct lead_id) unique_leads, count(distinct partner_id) unique_partners from DailySales group by date_id,make_name

解題解析:

利用sql的distinct的關鍵字來過濾重複出現的紀錄值,這樣我們就可以取得題目所需要的不重複值