我想在条形图中显示所有工作日如何显示?我的查询没有返回所有工作日,我想在我的报告中显示所有工作日我该怎么做?
答案 0 :(得分:1)
您可以使用包含所有工作日的表格,然后将查询加入其中:例如
select * into #w from (
select DATENAME(dw, dateadd(dd,0,getdate() )) weedday union
select DATENAME(dw, dateadd(dd,1,getdate() )) weedday union
select DATENAME(dw, dateadd(dd,2,getdate() )) weedday union
select DATENAME(dw, dateadd(dd,3,getdate() )) weedday union
select DATENAME(dw, dateadd(dd,4,getdate() )) weedday union
select DATENAME(dw, dateadd(dd,5,getdate() )) weedday union
select DATENAME(dw, dateadd(dd,6,getdate() )) weedday ) x
select * into #d from (
select DATENAME(dw, dateadd(dd,4,getdate() )) weedday,15 amt union
select DATENAME(dw, dateadd(dd,4,getdate() )) weedday,50 amt union
select DATENAME(dw, dateadd(dd,4,getdate() )) weedday,19 amt union
select DATENAME(dw, dateadd(dd,5,getdate() )) weedday,15 amt union
select DATENAME(dw, dateadd(dd,5,getdate() )) weedday,30 amt union
select DATENAME(dw, dateadd(dd,5,getdate() )) weedday ,40 amt ) x
select w.weedday,d.amt
from #w w
left join #d d
on w.weedday = d.weedday