문제
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