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

    silver

    RSSยทPowered by Inblog