一条实现每一天统计数据的sql语句(sql server)

select telco,count(telco) as count,datediff(day,'2012-05-15',left(adate,8)) as arrayNo
from platform.dbo.akn_outgoing_log 
where resp_status=2 and adate>'20120515' and adate<'20120521'
      and telco in(0011,0003,0001)
      group by telco,datediff(day,'2012-05-15',left(adate,8)) order by telco,arrayNo

adate在数据库类型是字符串如:20120329153854

猜你喜欢

转载自lpm528.iteye.com/blog/1536455