【发布时间】:2020-10-13 23:48:32
【问题描述】:
如何将以下查询更改为按天而不是按月提取?
select CONVERT(CHAR(4), dCompletedDate, 100) + CONVERT(CHAR(4), dCompletedDate, 120) as MonthYear,
count(case when dCompletedDate is not null then 1 else 0 end) as 'Total Completes'
from TProfile a
left join TStudyTable b
on a.lhouseholdid=b.lhouseholdid
where
dcompleteddate >= '1/1/1990' and dcompleteddate < '1/1/2050'
group by CONVERT(CHAR(4), dCompletedDate, 100) + CONVERT(CHAR(4), dCompletedDate, 120)
order by MonthYear
【问题讨论】:
标签: sql sql-server date select count