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