본문 바로가기
언어

basic join: top competitors (medium)

by 땅호720 2024. 6. 14.

Julia just finished conducting a coding contest, and she needs your help assembling the leaderboard! Write a query to print the respective hacker_id and name of hackers who achieved full scores for more than one challenge. Order your output in descending order by the total number of challenges in which the hacker earned a full score. If more than one hacker received full scores in same number of challenges, then sort them by ascending hacker_id.

select s.hacker_id, h.name
from submissions s
join hackers h on s.hacker_id=h.hacker_id
join challenges c on c.challenge_id= s.challenge_id
join difficulty d on d.difficulty_level=c.difficulty_level
where d.score = s.score
group by s.hacker_id, h.name
having count(s.challenge_id) > 1
order by count(s.challenge_id) desc, s.hacker_id

 

'언어' 카테고리의 다른 글

with as  (0) 2024.06.18
mysql에 pivot 없음  (1) 2024.06.14
basic join: the report (medium)  (0) 2024.06.13
median: percent_rank  (0) 2024.06.12
Manhattan Distance  (0) 2024.06.11