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.
with s_b as (select c.contest_id, sum(isnull (s.total_submissions, 0)) as to_sub, sum(isnull (s.total_accepted_submissions, 0)) as to_ac_sub
from Contests c join Colleges cg on c.contest_id = cg.contest_id
join Challenges cl on cg.college_id = cl.college_id
left join Submission_Stats s on cl.challenge_id = s.challenge_id
group by c.contest_id),
_view as (select c.contest_id, sum(isnull (v.total_views, 0)) as to_view, sum(isnull (v.total_unique_views, 0)) as to_uq_view
from Contests c join Colleges cg on c.contest_id = cg.contest_id
join Challenges cl on cg.college_id = cl.college_id
left join View_Stats v on cl.challenge_id = v.challenge_id
group by c.contest_id)
select c.contest_id, c.hacker_id, c.name, s.to_sub, s.to_ac_sub, v.to_view, v.to_uq_view
from Contests c join s_b s on c.contest_id = s.contest_id
join _view v on c.contest_id = v.contest_id
order by c.contest_id;
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Interviews
You are viewing a single comment's thread. Return to all comments →
MICROSOFT SQL SERVER
with s_b as (select c.contest_id, sum(isnull (s.total_submissions, 0)) as to_sub, sum(isnull (s.total_accepted_submissions, 0)) as to_ac_sub from Contests c join Colleges cg on c.contest_id = cg.contest_id join Challenges cl on cg.college_id = cl.college_id left join Submission_Stats s on cl.challenge_id = s.challenge_id group by c.contest_id),
_view as (select c.contest_id, sum(isnull (v.total_views, 0)) as to_view, sum(isnull (v.total_unique_views, 0)) as to_uq_view from Contests c join Colleges cg on c.contest_id = cg.contest_id join Challenges cl on cg.college_id = cl.college_id left join View_Stats v on cl.challenge_id = v.challenge_id group by c.contest_id)
select c.contest_id, c.hacker_id, c.name, s.to_sub, s.to_ac_sub, v.to_view, v.to_uq_view from Contests c join s_b s on c.contest_id = s.contest_id join _view v on c.contest_id = v.contest_id order by c.contest_id;