select * from 表名 where 时间 between '开始时间' and '结束时间'
oracle
如:
select * from 表名 where 时间 >=to_date('2009-01-01','yyyy-mm-dd') and 时间 <= to_date('2009-02-01','yyyy-mm-dd')
时间段统计,可以采用 hour(subscribe_time) 取出小时然后分层。思路:select
uid
,CASE WHEN HOUR(subscribe_time) BETWEEN 0 AND 1 THEN '00:00:00'
WHEN HOUR(subscribe_time) BETWEEN 2 AND 3 THEN '02:00:00'
...
ELSE '23:00:00' END -- 生成时间分层部分,insert前外层sql加上日期后作为唯一的时间值
,COUNT(*)
FROM yht_fans WHERE subscribe_time>=UNIX_TIMESTAMP(CURDATE()) and subscribe_time<=UNIX_TIMESTAMP(CURDATE())+86400
GROUP BY 1,2
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)