문제 URL : https://solvesql.com/problems/multiple-medalist/
https://solvesql.com/problems/multiple-medalist/
solvesql.com
*문제 저작권으로 인하여 직접 작성한 쿼리문만 첨부
select athletes.name
from athletes, records, games
where athletes.id = records.athlete_id
and records.game_id = games.id
and medal is not null
and year >= 2000
group by athlete_id
having count(distinct team_id) > 1
order by name
3개의 테이블을 조인하기 위하여 WHERE절을 이용한 Multiple Joins를 적용
count(~)를 where절 내에 작성했다가 "misuse of aggregate: count()" 오류 발생 -> having절 내에 작성하여 해결
'Problem Solving' 카테고리의 다른 글
[SolveSQL] 할부는 몇 개월로 해드릴까요 (0) | 2025.02.05 |
---|---|
[백준] 1515-수 이어 쓰기 (1) | 2025.02.04 |
[SolveSQL] 쇼핑몰의 일일 매출액 (0) | 2025.02.04 |
[SolveSQL] 우리 플랫폼에 정착한 판매자 1 (0) | 2025.02.03 |
[SolveSQL] 최근 올림픽이 개최된 도시 (0) | 2025.02.03 |