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 b.hacker_id, a.name, b.tot_cha from hackers a
join
(select hacker_id, count(challenge_id) as tot_cha from challenges group by hacker_id)b
on a.hacker_id = b.hacker_id where b.tot_cha not in
(select c.tot_cha from
(select hacker_id, count(challenge_id) as tot_cha from challenges group by hacker_id)c
where c.tot_cha !=
(select count(challenge_id) as tot_cha from challenges group by hacker_id order by tot_cha desc limit 1)
group by c.tot_cha having count(c.tot_cha) > 1)
order by b.tot_cha desc, b.hacker_id;
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 →
Here is my solution and its working:
select b.hacker_id, a.name, b.tot_cha from hackers a join (select hacker_id, count(challenge_id) as tot_cha from challenges group by hacker_id)b on a.hacker_id = b.hacker_id where b.tot_cha not in (select c.tot_cha from (select hacker_id, count(challenge_id) as tot_cha from challenges group by hacker_id)c where c.tot_cha != (select count(challenge_id) as tot_cha from challenges group by hacker_id order by tot_cha desc limit 1) group by c.tot_cha having count(c.tot_cha) > 1) order by b.tot_cha desc, b.hacker_id;