[MSQL]ハッカーランキング(HackerRank)-ConTest LeaderBoard


https://www.hackerrank.com/challenges/contest-leaderboard/problem?isFullScreen=true
質問する

解析
ハッカーの総得点はすべての挑戦の最大得点の合計です.クエリーを作成して、降順スコアでソートされたハッカーのhacker id、名前、および合計スコアを出力します.複数のハッカーが同じ合計スコアを取得した場合、hacker id昇順に結果をソートします.合計0に分かれたすべてのハッカーをあなたの結果から除外します.
select
    h.hacker_id
,   h.name
,   sum(score)
from
    (
    select
        hacker_id
    ,   challenge_id
    ,   max(score) as score
    from
        submissions
    group by
        hacker_id
    ,   challenge_id
    ) as t
    join hackers as h on t.hacker_id = h.hacker_id
group by
    h.hacker_id
,   h.name
having
    sum(score) > 0
order by
    sum(score) desc
,   h.hacker_id