• + 1 comment

    anyone know what is wrong?

    SELECT c.contest_id, c.hacker_id, c.name, 
           SUM(s.total_submissions) AS total_submissions, 
           SUM(s.total_accepted_submissions) AS total_accepted_submissions, 
           SUM(v.total_views) AS total_views, 
           SUM(v.total_unique_views) AS total_unique_views 
    FROM Contests c 
    JOIN Colleges cl ON c.contest_id = cl.contest_id 
    JOIN Challenges ch ON ch.college_id = cl.college_id 
    JOIN View_Stats v ON v.challenge_id = ch.challenge_id 
    JOIN Submission_Stats s ON s.challenge_id = ch.challenge_id 
    GROUP BY c.contest_id, c.hacker_id, c.name 
    HAVING SUM(s.total_submissions) + SUM(s.total_accepted_submissions) + SUM(v.total_views) + SUM(v.total_unique_views) > 0 
    ORDER BY c.contest_id