𝙎𝙌𝙇

[HackerRank] Challenges

콜라맛갈비 2023. 7. 12. 17:50
728x90

https://www.hackerrank.com/challenges/challenges/problem?isFullScreen=true 

 

Challenges | HackerRank

Print the total number of challenges created by hackers.

www.hackerrank.com

with cnt as(
    select h.hacker_id
        , h.name
        , count(challenge_id) challenges_created
    from hackers h left join challenges c
        on h.hacker_id = c.hacker_id
    group by h.hacker_id, h.name
    order by 3 desc, 1
    )

select *
from cnt
where challenges_created in (
    select max(challenges_created)
    from cnt
    union
    select challenges_created
    from cnt
    group by challenges_created
    having count(*) = 1
    )
728x90