🤔 문제 분석
1) Write an SQL query that will, for each date_id and make_name, return the number of distinct lead_id's and distinct partner_id's.
2) Return the result table in any order.
💡 풀이
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
'코딩테스트 > 리트코드 SQL' 카테고리의 다른 글
[리트코드/SQL] 23. Customer Placing the Largest Number of Orders (586) (0) | 2022.12.18 |
---|---|
[리트코드/SQL] 22. Find Followers Count (1729) (0) | 2022.12.18 |
[리트코드/SQL] 20. User Activity for the Past 30 Days I (1141) (0) | 2022.12.18 |
[리트코드/SQL] 19. Sales Person (607) (0) | 2022.12.18 |
[리트코드/SQL] 18. Rising Temperature (197) (0) | 2022.12.18 |
댓글