We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
SELECT t.list_hacker, name.name, t.Total_challenge
FROM (
SELECT
hacker_id AS list_hacker,
COUNT(challenge_id) AS Total_challenge,
COUNT(*) OVER (PARTITION BY COUNT(challenge_id)) AS challenge_cnt
FROM Challenges
GROUP BY hacker_id
) AS t
LEFT JOIN Hackers name
ON t.list_hacker = name.hacker_id
WHERE challenge_cnt = 1
OR Total_challenge = (
SELECT MAX(cnt)
FROM (
SELECT COUNT(challenge_id) AS cnt
FROM Challenges
GROUP BY hacker_id
) AS sub
)
ORDER BY t.Total_challenge DESC, t.list_hacker ;
Cookie support is required to access HackerRank
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 →
SELECT t.list_hacker, name.name, t.Total_challenge FROM ( SELECT hacker_id AS list_hacker, COUNT(challenge_id) AS Total_challenge, COUNT(*) OVER (PARTITION BY COUNT(challenge_id)) AS challenge_cnt FROM Challenges GROUP BY hacker_id ) AS t LEFT JOIN Hackers name ON t.list_hacker = name.hacker_id WHERE challenge_cnt = 1 OR Total_challenge = ( SELECT MAX(cnt) FROM ( SELECT COUNT(challenge_id) AS cnt FROM Challenges GROUP BY hacker_id ) AS sub ) ORDER BY t.Total_challenge DESC, t.list_hacker ;