sqlserver 如何显示一周的列表
[*]当前只能获取有数据的日期
[*]比如我想展示信息是: 周一 0 周二 0 周三 0 周四 0 周五 0 周六 0 周日 0
没数据也要显示SET DATEFIRST 1--设置星期一为每周的开始select
case
when tt.dayOnweek='星期天' then '周日'
else replace(tt.dayOnweek,'星期','周')
end as dayOnweek,ISNULL(tt.RYCount,0) as RYCount from
(
select
dayOnweek,
count(RYCount) as RYCount from(
select
MineName,
datename(Weekday,DownWellTime) as dayOnweek,
count(WorkNumber) as RYCount
from
where DATEDIFF(WK,DATEADD(DD,-@@DATEFIRST,GETDATE()),DATEADD(DD,-@@DATEFIRST,DownWellTime))=0
group by DownWellTime,WorkNumber,MineName
)as t
group by t.dayOnweek,t.RYCount
)as tt
order by charindex(substring(tt.dayOnweek,3,1),'一二三四五六日')
参考下这个链接https://ask.csdn.net/questions/1085274 https://ask.csdn.net/questions/1085274看下这个
页:
[1]