• + 1 comment

    Guys check this solution

    select t1.contest_id, t1.hacker_id,t1.name, t2.ts, t2.tas, t1.tv,t1.tuv from 
    (select con.contest_id, con.hacker_id, con.name, sum(total_views) as tv, sum(total_unique_views) as tuv
    from 
        view_stats as vs, challenges as chal, colleges as col, contests as con
        where 
        vs.challenge_id = chal.challenge_id and
        chal.college_id = col.college_id and
        col.contest_id = con.contest_id
    group by con.contest_id, con.hacker_id, con.name
    order by contest_id) as t1, 
    (
        select con.contest_id, con.name, sum(total_submissions) as ts, sum(total_accepted_submissions) as tas 
    from 
        submission_stats as ss, challenges as chal, colleges as col, contests as con
        where
        ss.challenge_id = chal.challenge_id and 
        chal.college_id = col.college_id and 
        col.contest_id = con.contest_id
    group by con.contest_id, con.name
    order by contest_id) as t2
    where t1.contest_id = t2.contest_id