我有两个代码片段,它们产生不同的输出。请问任何人都可以建议我犯错的地方吗?
第一段代码:
sum[i] = 2;
i = i + 1;
第二段代码:
select
a.contest_id,
B.hacker_id,
B.name,
SUM(e.total_submissions)total_submissions,
SUM(e.total_accepted_submission) total_accepted_submission,
SUM(total_view)total_view,
SUM(total_unique_views) total_unique_views
from
Contests b
inner join
Colleges a on A.contest_id = B.contest_id
left join
Challenges c on a.college_id = c.college_id
left join
(select
challenge_id,
SUM(total_views) total_view,
sum(total_unique_views) total_unique_views
from
View_Stats
group by challenge_id) d on c.challenge_id = d.challenge_id
left join
(select
challenge_id,
SUM(total_submissions) total_submissions,
SUM(total_accepted_submission) total_accepted_submission
from
Submission_Stats
group by
challenge_id) e on e.challenge_id = d.challenge_id
group by
a.contest_id, b.hacker_id, B.name
having
(sum(total_submissions) +
sum(total_accepted_submission) +
sum(total_view) + sum(total_unique_views)) <> 0
order by
a.contest_ID
问题在于总提交的值和total_accepted_submission
答案 0 :(得分:1)
第一个示例中有LEFT JOIN Challenges
,第二个示例中有INNER JOIN Challenges
。