SQL/SQLite

[SQLite][문제풀이] 레스토랑 요일 별 구매 금액 Top3 영수증

jihuSunbae 2024. 11. 11. 22:00

 

 

목차

     

     

    🫡 Overview

    체감 난이도: 

    소요시간: 

    문제 레벨: lv4
    풀이 상태:  답안참고
    추후: 다시 풀어보기

     


    문제 링크

    https://solvesql.com/problems/top-3-bill/

     

    https://solvesql.com/problems/top-3-bill/

     

    solvesql.com

     

     

    나의 코드

    SELECT day, time, sex, total_bill
    FROM tips
    WHERE (day, total_bill) IN (
        SELECT day, total_bill
        FROM tips t
        WHERE (
            SELECT COUNT(*)
            FROM tips t2
            WHERE t2.day = t.day
            AND t2.total_bill >= t.total_bill
        ) <= 3
    )
    ORDER BY day, total_bill DESC;

     

     

     

    'SQL > SQLite' 카테고리의 다른 글

    [SQLite] JOIN  (0) 2024.10.04
    [SQLite] CASE IF  (1) 2024.10.03
    [SQLite] LEAD OVER 구문  (1) 2024.10.03
    [SQLite] with 구문  (1) 2024.10.03
    [SQLite] datetime 관련 함수  (1) 2024.10.03