[hackerrank] MySQL - Challenges Smelt Roe Sushi

데이터 분석/[SQL] 기초

[hackerrank] MySQL - Challenges

INCHELIN 2025. 3. 20. 14:19
728x90

https://www.hackerrank.com/challenges/challenges/problem

Challenges | HackerRank

Print the total number of challenges created by hackers.

www.hackerrank.com


with t1 as(
select hacker_id, count(distinct challenge_id) as c_cnt
from challenges
group by hacker_id
    )
select t1.hacker_id, hackers.name, c_cnt
from t1
join hackers on t1.hacker_id = hackers.hacker_id
where 1=1
    and (t1.c_cnt = (select max(c_cnt) from t1)
        or
         t1.c_cnt not in (select c_cnt from t1
                         group by c_cnt having count(c_cnt)>=2)
         )
order by c_cnt desc, hacker_id asc

728x90