• + 0 comments

    SELECT c.contest_id, c.hacker_id,c.name , s.ts, s.tas, v.tv, v.tuv from contests c inner join (SELECT c.contest_id, sum(total_submissions) as ts, sum(total_accepted_submissions) as tas FROM contests c INNER JOIN colleges cl ON cl.contest_id=c.contest_id INNER JOIN challenges ch ON cl.college_id=ch.college_id INNER JOIN submission_stats ss ON ss.challenge_id=ch.challenge_id GROUP BY c.contest_id having SUM(total_submissions)+SUM(total_accepted_submissions) > 0) s ON c.contest_id=s.contest_id INNER JOIN ( SELECT c.contest_id, sum(total_views) as tv, sum(total_unique_views) as tuv FROM contests c INNER JOIN colleges cl ON cl.contest_id=c.contest_id INNER JOIN challenges ch ON cl.college_id=ch.college_id INNER JOIN view_stats vs ON vs.challenge_id=ch.challenge_id GROUP BY c.contest_id having SUM(total_views)+SUM(total_unique_views) > 0 ) v ON v.contest_id=s.contest_id;