Posted on 2012-03-05 12:51
小白19870626 阅读(420)
评论(0) 编辑 收藏 所属分类:
oracle
在查询大数据量的时候,可以用TO_DATE('2011-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')将数据按时间分开查询,提高速度
select * from (
select send_time,src_id, count(*) count_
from(
select src_id ,to_char(send_time,'yyyymm') send_time
from mms_mt_log
where send_time >= TO_DATE('2011-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
and send_time <= TO_DATE('2011-06-30 23:59:59', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
and (sub_status = 1000 or sub_status = 4446)
)
group by send_time, src_id
)order by src_id
小白