문제 풀이 링크: https://www.hackerrank.com/challenges/contest-leaderboard/problem?isFullScreen=true
Contest Leaderboard | HackerRank
Generate the contest leaderboard.
www.hackerrank.com
🧾 Contest Leaderboard 문제 요약
- 목적
- 해커별로 각 챌린지에서 받은 최고 점수만 합산하여 총 점수(total score)를 계산하고, 총점이 0점 초과인 해커만 출력
- 출력 항목:
- hacker_id
- name
- total_score (챌린지별 최고 점수들의 합계)
- 정렬 기준:
- total_score 기준 내림차순
- 동점일 경우 hacker_id 기준 오름차순
- 조건:
- 총점이 0점인 해커는 제외
SELECT h.hacker_id,
h.name,
SUM(s.max_score) total_score
FROM Hackers h
JOIN (
SELECT hacker_id,
challenge_id,
MAX(score) AS max_score
FROM Submissions
GROUP BY hacker_id, challenge_id
) s
ON h.hacker_id = s.hacker_id
GROUP BY h.hacker_id, h.name
HAVING total_score > 0
ORDER BY total_score DESC, h.hacker_id;
'SQL' 카테고리의 다른 글
Top Competitors (0) | 2025.05.06 |
---|---|
The Report (0) | 2025.05.05 |
Binary Tree Nodes (0) | 2025.05.05 |
Weather Observation Station 19 (0) | 2025.05.05 |
Draw The Triangle1, 2 (0) | 2025.05.05 |