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 x.id,
x.nam,
SUM(x.scr)
FROM(
SELECT s.challenge_id AS ch_id,
h.hacker_id AS id,
h.name AS nam,
MAX(s.score) AS scr
FROM Hackers h
LEFT JOIN Submissions s ON s.hacker_id = h.hacker_id
GROUP BY s.challenge_id,
h.hacker_id,
h.name
HAVING MAX(s.score) <> 0
) AS x
GROUP BY x.id,
x.nam
ORDER BY SUM(x.scr) DESC, x.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 →
SELECT x.id, x.nam, SUM(x.scr) FROM( SELECT s.challenge_id AS ch_id, h.hacker_id AS id, h.name AS nam, MAX(s.score) AS scr FROM Hackers h LEFT JOIN Submissions s ON s.hacker_id = h.hacker_id GROUP BY s.challenge_id, h.hacker_id, h.name HAVING MAX(s.score) <> 0
) AS x GROUP BY x.id, x.nam ORDER BY SUM(x.scr) DESC, x.id