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 bb.contest_id, bb.hacker_id, bb.name, SUM(cc.ttsm), SUM(cc.ttasm), SUM(dd.ttv), SUM(dd.ttuv)
FROM (SELECT ch.challenge_id, aa.contest_id, aa.hacker_id, aa.name
FROM (SELECT cl.college_id, ct.contest_id, ct.hacker_id, ct.name
FROM contests ct
JOIN colleges cl USING (contest_id)) aa
JOIN challenges ch USING (college_id)) bb
LEFT JOIN
(SELECT ch.challenge_id, sum(total_submissions) AS ttsm, sum(total_accepted_submissions) AS ttasm
FROM challenges ch
JOIN submission_stats ss ON ch.challenge_id = ss.challenge_id
GROUP BY ch.challenge_id) cc
ON bb.challenge_id = cc.challenge_id
LEFT JOIN
(SELECT ch.challenge_id, sum(total_views) AS ttv, sum(total_unique_views) AS ttuv
FROM challenges ch
JOIN view_stats vs ON ch.challenge_id = vs.challenge_id
GROUP BY ch.challenge_id) dd
ON bb.challenge_id = dd.challenge_id
GROUP BY bb.contest_id, bb.hacker_id, bb.name
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 →
MySQL
SELECT bb.contest_id, bb.hacker_id, bb.name, SUM(cc.ttsm), SUM(cc.ttasm), SUM(dd.ttv), SUM(dd.ttuv) FROM (SELECT ch.challenge_id, aa.contest_id, aa.hacker_id, aa.name FROM (SELECT cl.college_id, ct.contest_id, ct.hacker_id, ct.name FROM contests ct JOIN colleges cl USING (contest_id)) aa JOIN challenges ch USING (college_id)) bb LEFT JOIN (SELECT ch.challenge_id, sum(total_submissions) AS ttsm, sum(total_accepted_submissions) AS ttasm FROM challenges ch JOIN submission_stats ss ON ch.challenge_id = ss.challenge_id GROUP BY ch.challenge_id) cc ON bb.challenge_id = cc.challenge_id LEFT JOIN (SELECT ch.challenge_id, sum(total_views) AS ttv, sum(total_unique_views) AS ttuv FROM challenges ch JOIN view_stats vs ON ch.challenge_id = vs.challenge_id GROUP BY ch.challenge_id) dd ON bb.challenge_id = dd.challenge_id GROUP BY bb.contest_id, bb.hacker_id, bb.name