HackerRank MySQL - Revising the Select Query ITop Competitors




Julia just finished conducting a coding contest, and she needs your help assembling the leaderboard! Write a query to print the respective hacker_id and name of hackers who achieved full scores for more than one challenge. Order your output in descending order by the total number of challenges in which the hacker earned a full score. If more than one hacker received full scores in same number of challenges, then sort them by ascending hacker_id.



  1. SELECT H.HACKER_ID,
  2. H.NAME
  3. FROM HACKERS H
  4. JOIN SUBMISSIONS S ON H.HACKER_ID = S.HACKER_ID
  5. JOIN DIFFICULTY D ON S.SCORE = D.SCORE
  6. JOIN CHALLENGES C ON S.CHALLENGE_ID = C.CHALLENGE_ID
  7. AND D.DIFFICULTY_LEVEL = C.DIFFICULTY_LEVEL
  8. GROUP BY H.HACKER_ID,
  9. H.NAME
  10. HAVING COUNT(S.SUBMISSION_ID) > 1
  11. ORDER BY COUNT(S.SUBMISSION_ID) DESC, HACKER_ID ASC;




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