我有这个查询有效,但结果不像我想要的
只返回有数据的年份和周数,我想将0返回到结果
例如,返回
year week totalstop
2017 50 7
2018 1 3
2018 3 5
但我想返回
year week totalstop
2017 50 7
2017 51 0
2017 52 0
2018 1 3
2018 2 0
2018 3 5
等等
这是当前查询
SELECT year(Stopdate)[year],datepart(week,date1) [week],sum(stop) totalstop
from Table1 where
building in (select item from dbo.fn_Split('A1,A2,A3,A4,A5',','))
and
date1 between '2017-12-12' and '2018-05-08'
and grp = 1
group by year(date1),datepart(week,date1)
order by year(date1),[week]
iam使用ms sql-server 2016
需要帮助来根据我的想法修改它以满足我的需求。