1、按日统计:
select convert(varchar(13),RingTime,120) as RingTime,count(*) as DialCount
from D_CallRecords (nolock) group by convert(varchar(13),RingTime,120)
2、按周统计:
select datename(dw,dateadd(dd,-1,D_CallRecords.RingTime)) as RingTime from D_CallRecords
group by datename(dw,dateadd(dd,-1,D_CallRecords.RingTime))
3、按月统计:
select day([RingTime]) as RingTime from D_CallRecords (nolock) where year([RingTime]) =2014 and month([RingTime]) =6 group by day([RingTime])
4、按年统计:
select month([RingTime]) as Months from D_CallRecords (nolock) where year([RingTime]) =2014 group by month([RingTime])
还没有评论,来说两句吧...