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.
**MYSQL**
SELECT h.hacker_id, h.name, SUM(maxScore) AS totalScore
FROM hackers h
JOIN (
SELECT MAX(score) AS maxScore, hacker_id, challenge_id
FROM submissions
GROUP BY hacker_id, challenge_id
) AS sub ON sub.hacker_id = h.hacker_id
GROUP BY h.hacker_id, h.name
HAVING totalScore > 0
order by totalScore desc,h.hacker_id;
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 →
**MYSQL** SELECT h.hacker_id, h.name, SUM(maxScore) AS totalScore FROM hackers h JOIN ( SELECT MAX(score) AS maxScore, hacker_id, challenge_id FROM submissions GROUP BY hacker_id, challenge_id ) AS sub ON sub.hacker_id = h.hacker_id GROUP BY h.hacker_id, h.name HAVING totalScore > 0 order by totalScore desc,h.hacker_id;