日期:2014-05-17 浏览次数:21174 次
//昨天 select count(1) as yesterday from XX where datediff(d,ProgDate,getdate())=1 //今天 select count(1) as today from XX where datediff(d,ProgDate,getdate())=0
------解决方案--------------------
其实这点儿事儿用SQL自己的时间函数就解决了
select count(*) from table where createdate >= date(now());
select count(*) from table where createdate >= date_add(date(now()), interval -1 day) and createdate < date(now());
------解决方案--------------------
select convert(varchar(7),ViewDate,120) as month, COUNT(1) as NUM, from PageView
group by convert(varchar(7),ViewDate,120)
order by month desc
我是根据月份来取的 比如 3月10条 4月20条....
但是我始终依稀觉得这样效率应该不高。。。