标签:
循环30日的统计
大概格式是
with Date as ( select cast(DATEADD(mm, DATEDIFF(mm,0,getdate()), 0) as datetime) Date union all select Date+1 from Date where Date+1 < CONVERT(CHAR(10),DATEADD(m,1,DATEADD(dd,-DAY(GETDATE())+1,GETDATE())),111) ) select day(a.Date) as day, b.ID, from Date a left join ( select * from Table) b on year(a.Date) = year(b.DATE) and month(a.Date) = month(b.DATE) and day(a.Date) = day(b.DATE);
标签:
原文地址:http://www.cnblogs.com/objctccc/p/5334017.html