HackerRank MySQL - Contest Leaderboard
You did such a great job helping Julia with her last coding contest challenge that she wants you to work on this one, too!
The total score of a hacker is the sum of their maximum scores for all of the challenges. Write a query to print the hacker_id, name, and total score of the hackers ordered by the descending score. If more than one hacker achieved the same total score, then sort the result by ascending hacker_id. Exclude all hackers with a total score of 0 from your result.
- SELECT HACKER_ID,
- (SELECT S.HACKER_ID,
- MAX(S.SCORE) A
- FROM SUBMISSIONS S
- INNER JOIN HACKERS H ON H.HACKER_ID=S.HACKER_ID
- WHERE S.SCORE!=0
- GROUP BY S.HACKER_ID,
- GROUP BY HACKER_ID,
- ORDER BY 3 DESC,