Contest Leaderboard

  • + 0 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