You are viewing a single comment's thread. Return to all comments →
Here's my attempt to solve the task using MSSQL's CTE:
WITH COUNTS AS ( SELECT HACKER_ID, COUNT(CHALLENGE_ID) AS TOTALCNT FROM CHALLENGES GROUP BY HACKER_ID) SELECT H.HACKER_ID, H.NAME, C.TOTALCNT FROM HACKERS H JOIN COUNTS C ON H.HACKER_ID = C.HACKER_ID WHERE C.TOTALCNT = (SELECT MAX(TOTALCNT) FROM COUNTS) OR C.TOTALCNT NOT IN ( SELECT TOTALCNT FROM COUNTS AS T WHERE H.HACKER_ID != T.HACKER_ID) ORDER BY C.TOTALCNT DESC, H.HACKER_ID
Seems like cookies are disabled on this browser, please enable them to open this website
Challenges
You are viewing a single comment's thread. Return to all comments →
Here's my attempt to solve the task using MSSQL's CTE: