inblog logo
|
silver
    SQL문제풀기

    [SQL문제풀기] 복수 국적 메달 수상한 선수 찾기

    silver's avatar
    silver
    Mar 04, 2025
    [SQL문제풀기] 복수 국적 메달 수상한 선수 찾기
    Contents
    문제SQLite

    문제

    solvesql.com
    solvesql.com
    https://solvesql.com/problems/multiple-medalist/

    SQLite

    내가 작성한 정답

    : team_id ( = t.id)에 distinct를 넣지 않으면 메달을 2개이상 딴 사람들은 모두 출력되므로 distinct! 중요!
    select a.name from records r join teams t on r.team_id = t.id join (select id, year from games group by year, id having year >= 2000) g on r.game_id = g.id join athletes a on r.athlete_id = a.id where r.medal is not null group by r.athlete_id having count(distinct t.id)>= 2 order by 1 asc
    Share article

    silver

    RSS·Powered by Inblog