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.
SELECT
h.hacker_id,
h.name,
SUM(t.max_score) AS total_score
FROM
hackers AS h
INNER JOIN (
SELECT
sub.hacker_id,
sub.challenge_id,
MAX(sub.score) AS max_score
FROM
submissions AS sub
GROUP BY
sub.hacker_id,
sub.challenge_id
) AS t ON t.hacker_id = h.hacker_id
GROUP BY
h.hacker_id,
h.name
HAVING
SUM(t.max_score) > 0
ORDER BY
total_score DESC,
h.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 →
SELECT h.hacker_id, h.name, SUM(t.max_score) AS total_score FROM hackers AS h INNER JOIN ( SELECT sub.hacker_id, sub.challenge_id, MAX(sub.score) AS max_score FROM submissions AS sub GROUP BY sub.hacker_id, sub.challenge_id ) AS t ON t.hacker_id = h.hacker_id GROUP BY h.hacker_id, h.name HAVING SUM(t.max_score) > 0 ORDER BY total_score DESC, h.hacker_id ASC;