• + 6 comments

    Please help!

    why this code is not working ? I removed only the sub-queries and it is giving larger values. I don't understand why sub-queries is making any difference.

    Changed code :

    select con.contest_id,
            con.hacker_id, 
            con.name, 
            sum(total_submissions), 
            sum(total_accepted_submissions), 
            sum(total_views), sum(total_unique_views)
        from contests con 
        join colleges col on con.contest_id = col.contest_id 
        join challenges cha on  col.college_id = cha.college_id 
    
            left join view_stats vs 
            on cha.challenge_id = vs.challenge_id 
            left join submission_stats ss
            on cha.challenge_id = ss.challenge_id
    
        group by con.contest_id, con.hacker_id, con.name
        having sum(total_submissions)!=0 or 
        sum(total_accepted_submissions)!=0 or
        sum(total_views)!=0 or
        sum(total_unique_views)!=0
        order by contest_id;