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.
ngoccth_SQL SERVER:
WITH table_1 AS (
SELECT sub.hacker_id, name, challenge_id, score
, ROW_NUMBER () OVER (PARTITION BY sub.hacker_id, challenge_id ORDER BY score DESC) AS row_num
FROM Submissions AS Sub
JOIN Hackers AS Hac ON Sub.hacker_id = Hac.hacker_id
)
SELECT hacker_id, name
, SUM (score)
FROM table_1
WHERE row_num = 1
GROUP BY hacker_id, name
HAVING SUM (score) != 0
ORDER BY SUM (score) DESC, 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 →
ngoccth_SQL SERVER: WITH table_1 AS ( SELECT sub.hacker_id, name, challenge_id, score , ROW_NUMBER () OVER (PARTITION BY sub.hacker_id, challenge_id ORDER BY score DESC) AS row_num FROM Submissions AS Sub JOIN Hackers AS Hac ON Sub.hacker_id = Hac.hacker_id ) SELECT hacker_id, name , SUM (score) FROM table_1 WHERE row_num = 1 GROUP BY hacker_id, name HAVING SUM (score) != 0 ORDER BY SUM (score) DESC, hacker_id