[LeetCode] Daily Leads and Partners


Problem 1693. Daily Leads and Partners

Concept

COUNT 関数に DISTINCT を使うことで、重複を排除したカウントする

MySQL Reference

Code

SELECT 
    date_id,
    make_name,
    COUNT(DISTINCT lead_id) AS unique_leads,
    COUNT(DISTINCT partner_id) AS unique_partners
FROM
    DailySales
GROUP BY
    date_id,
    make_name