You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem Statement: https://www.hackerrank.com/challenges/challenges/problem
@Coded by TSG, 2020
'''
/*
Enter your query here.
Please append a semicolon ";" at the end of the query and enter your query in a single line to avoid error.
*/
WITH PARTITIONED AS (SELECTc.hacker_id, COUNT(c.challenge_id) AS count_chal,ROW_NUMBER() OVER (PARTITION BY COUNT(c.challenge_id) ORDER BYc.hacker_id) AS rown FROM Challenges c GROUP BYc.hacker_id)
SELECTh.hacker_id, h.name,p.count_chalFROM Hackers h INNER JOIN PARTITIONED p ONh.hacker_id=p.hacker_idWHERE (p.count_chal=(SELECTMAX(count_chal) FROM PARTITIONED) ORp.count_chal NOT IN (SELECT count_chal FROM PARTITIONED where rown=2)) ORDER BYp.count_chaldesc, h.hacker_id;