[SQL문제풀기 - Advent of SQL 2025 🎅] 도시별 VIP 고객 찾기

silver's avatar
Dec 23, 2025
[SQL문제풀기 - Advent of SQL 2025 🎅] 도시별 VIP 고객 찾기

문제

내가 작성한 정답

MySQL, PostgreSQL, SQLite

with a as (select city_id, customer_id, sum(total_price)-sum(discount_amount) total_spent from transactions where not is_returned group by city_id, customer_id) select city_id, customer_id, total_spent from a where (city_id, total_spent) in (select city_id, max(total_spent) from a group by city_id) order by 1;
Share article