Contest Leaderboard | HackerRank
Generate the contest leaderboard.
www.hackerrank.com
Q>
해커아이디, 해커 이름, 스코어 점수 나타내기
C>
- 조건은 hacker_id와 Challenge_id를 그룹바이 기준으로 최대값 찾기
H>
select
hacker_id
, challenge_id
, max(score) score
from submissions
group by hacker_id, challenge_id
A>
with mx as
(select hacker_id, challenge_id ,max(score) score
from submissions
group by hacker_id, challenge_id ),
ss as
(select hacker_id ,sum(score) score
from mx
group by hacker_id
having sum(score) !=0)
select h.hacker_id
, h.name
, ss.score
from hackers h
join ss
on h.hacker_id = ss.hacker_id
group by h.hacker_id, h.name, ss.score
order by score desc, h.hacker_id;
'SQL > HackerRank' 카테고리의 다른 글
HackerRank - Weather Observation Station 18,19,20 (0) | 2023.01.24 |
---|---|
HackerRank - Type of Triangle (0) | 2023.01.24 |
HackerRank-Occupations (0) | 2023.01.24 |