inblog logo
|
silver
    SQL문제풀기

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

    silver's avatar
    silver
    Dec 23, 2025
    [SQL문제풀기 - Advent of SQL 2025 🎅] 도시별 VIP 고객 찾기
    Contents
    문제내가 작성한 정답

    문제

    solvesql.com
    solvesql.com
    https://solvesql.com/problems/vip-of-cities/

    내가 작성한 정답

    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
    Contents
    문제내가 작성한 정답

    silver

    RSS·Powered by Inblog