两段关于统计日期的sql语句
统计月份:
select left(convert(char(10),[Article_TimeDate],102),7) as 月份, count(*) as 数量
from [hdsource].[dbo].[article]
group by left(convert(char(10),[Article_TimeDate],102),7)
order by 1
统计年份:
from [hdsource].[dbo].[article]
group by left(convert(char(10),[Article_TimeDate],102),7)
order by 1
select left(convert(char(10),[Article_TimeDate],102),4) as 年份, count(*) as 数量
from [hdsource].[dbo].[article]
group by left(convert(char(10),[Article_TimeDate],102),4)
order by 1
from [hdsource].[dbo].[article]
group by left(convert(char(10),[Article_TimeDate],102),4)
order by 1