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.
The following tables contain contest data:
Hacker 86870 got a score of 30 for challenge 71055 with a difficulty level of 2, so 86870 earned a full score for this challenge.
Hacker 90411 got a score of 30 for challenge 71055 with a difficulty level of 2, so 90411 earned a full score for this challenge.
Hacker 90411 got a score of 100 for challenge 66730 with a difficulty level of 6, so 90411 earned a full score for this challenge.
Only hacker 90411 managed to earn a full score for more than one challenge, so we print the their hacker_id and name as 2 space-separated values.
SELECT h.hacker_id, h.name FROM submissions s INNER JOIN challenges c ON s.challenge_id = c.challenge_id INNER JOIN difficulty d ON c.difficulty_level = d.difficulty_level INNER JOIN hackers h ON s.hacker_id = h.hacker_id WHERE s.score = d.score AND c.difficulty_level = d.difficulty_level GROUP BY h.hacker_id, h.name HAVING COUNT(s.hacker_id) > 1 ORDER BY COUNT(s.hacker_id) DESC, s.hacker_id ASC
SELECT h.hacker_id,h.name FROM hackers h,challenges c ,difficulty d,submissions s WHERE h.hacker_id=s.hacker_id AND c.challenge_id=s.challenge_id AND c.difficulty_level=d.difficulty_level AND s.score=d.score GROUP BY h.hacker_id,h.name HAVING COUNT(h.hacker_id)>1 ORDER BY COUNT(c.challenge_id) DESC, h.hacker_id