[LeetCode/MySQL50] 1581. Customer Who Visited but Did Not Make Any Transactions
2025. 1. 22. 05:49ㆍ개인활동/코테
반응형
Problem
Solution
# Write your MySQL query statement below
select v.customer_id, count(v.customer_id) as count_no_trans
from Visits v
left outer join Transactions t on v.visit_id = t.visit_id
where t.transaction_id is null
group by v.customer_id;
- group by를 통해 customer_id별 aggregation
- left outer join을 활용해 Transaction이 생성되지 않은 id를 살려둘 수 있도록 함
- join 후 transaction_id가 null값인 경우만 추출
반응형
'개인활동 > 코테' 카테고리의 다른 글
[LeetCode/MySQL50] 1661. Average Time of Process per Machine (0) | 2025.02.03 |
---|---|
[LeetCode/MySQL50] 197. Rising Temperature (0) | 2025.01.28 |
[LeetCode/MySQL50] 1068. Product Sales Analysis I (0) | 2025.01.14 |
[LeetCode/MySQL50] 1378. Replace Employee ID With The Unique Identifier (0) | 2025.01.13 |
[LeetCode/MySQL50] 1683. Invalid Tweets (0) | 2025.01.13 |