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.
MY SQL:
SELECT A.hacker_id, A.name, SUM(B.score) AS total_score
FROM Hackers A
JOIN (
SELECT hacker_id, challenge_id, MAX(score) AS score
FROM Submissions
GROUP BY challenge_id, hacker_id
) B ON A.hacker_id = B.hacker_id
GROUP BY A.hacker_id, A.name
HAVING total_score > 0
ORDER BY total_score DESC, A.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 →
MY SQL: SELECT A.hacker_id, A.name, SUM(B.score) AS total_score FROM Hackers A JOIN ( SELECT hacker_id, challenge_id, MAX(score) AS score FROM Submissions GROUP BY challenge_id, hacker_id ) B ON A.hacker_id = B.hacker_id GROUP BY A.hacker_id, A.name HAVING total_score > 0 ORDER BY total_score DESC, A.hacker_id ASC;