sql-server-2016 - SQL 查询在其间的几周内返回 0
问题描述
我有这个有效的查询,但结果不是我想要的
只返回有数据的年和周,我想返回 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
需要帮助来修改它以满足我的需要,因为我没有想法 atm。
解决方案
推荐阅读
- android - 从数据库动态接收数据时设置文本的背景颜色
- c++ - 虽然循环不读取整个 ifstream 文件
- php - Docusign api - 代表另一个用户发送信封
- git - 在签出开发分支时,对来自其他分支的文件的更改仍然存在
- ios - iOS - 如何区分 UI 和单元测试,以及如何在这种具体情况下使用它们?
- c# - 使用 C# 和 Powershell 从 SQL Server 视图生成 CSV 文件时 CPU 使用率高
- reactjs - 我使用 android studio 在 linux 中运行 react native 应用程序。但我总是得到构建工具 27.0.3 的错误
- scala - Kryo 序列化问题 Spark
- vba - 是什么导致此下标超出范围错误?
- sorting - 对谷歌表格中的地址数据进行排序