We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
SQL SERVER
SELECT
HACKERS.HACKER_ID,
HACKERS.NAME,
SUM(MAX_SCORE.MAXSCORE) AS TOTALSCORE
FROM
(
SELECT
SUBMISSIONS.HACKER_ID,
SUBMISSIONS.CHALLENGE_ID,
MAX(SUBMISSIONS.SCORE) AS MAXSCORE
FROM SUBMISSIONS
GROUP BY SUBMISSIONS.HACKER_ID, SUBMISSIONS.CHALLENGE_ID
)
AS MAX_SCORE
JOIN HACKERS
ON HACKERS.HACKER_ID = MAX_SCORE.HACKER_ID
GROUP BY HACKERS.HACKER_ID, HACKERS.NAME
HAVING SUM(MAX_SCORE.MAXSCORE) <> 0
ORDER BY TOTALSCORE DESC, HACKERS.HACKER_ID ASC
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Contest Leaderboard
You are viewing a single comment's thread. Return to all comments →
SQL SERVER SELECT HACKERS.HACKER_ID, HACKERS.NAME, SUM(MAX_SCORE.MAXSCORE) AS TOTALSCORE FROM ( SELECT SUBMISSIONS.HACKER_ID, SUBMISSIONS.CHALLENGE_ID, MAX(SUBMISSIONS.SCORE) AS MAXSCORE FROM SUBMISSIONS GROUP BY SUBMISSIONS.HACKER_ID, SUBMISSIONS.CHALLENGE_ID ) AS MAX_SCORE JOIN HACKERS ON HACKERS.HACKER_ID = MAX_SCORE.HACKER_ID GROUP BY HACKERS.HACKER_ID, HACKERS.NAME HAVING SUM(MAX_SCORE.MAXSCORE) <> 0 ORDER BY TOTALSCORE DESC, HACKERS.HACKER_ID ASC