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.



  1. SELECT HACKER_ID,
  2. NAME,
  3. SUM(A)
  4. FROM
  5. (SELECT S.HACKER_ID,
  6. H.NAME,
  7. MAX(S.SCORE) A
  8. FROM SUBMISSIONS S
  9. INNER JOIN HACKERS H ON H.HACKER_ID=S.HACKER_ID
  10. WHERE S.SCORE!=0
  11. GROUP BY S.HACKER_ID,
  12. H.NAME,
  13. S.CHALLENGE_ID)
  14. GROUP BY HACKER_ID,
  15. NAME
  16. ORDER BY 3 DESC,
  17. 1;
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]


donate a cup of tea :)


Join Our Facebook Group

Share this solution






codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube