日期:2014-05-17 浏览次数:20498 次
create table OM_RT ( business_traffic NUMBER, finishtime DATE, center_id VARCHAR2(2) )
select sum(t.BUSINESS_TRAFFIC), '08:30-09:00' from OM_MCMS_AUTHLOG_RT t where T.FINISHTIME between to_date(((SUBSTR(to_char(sysdate, 'yyyy-mm-dd HH:mi:ss'), 1, 11)) || '08:30:00'), 'yyyy-mm-dd HH:mi:ss') and to_date(((SUBSTR(to_char(sysdate, 'yyyy-mm-dd HH:mi:ss'), 1, 11)) || '09:00:00'), 'yyyy-mm-dd HH:mi:ss') and T.CENTER_ID = '02'
--帮你简化下 select sum(decode(t.CENTER_ID,'01',t.BUSINESS_TRAFFIC,0)) 东公司, sum(decode(t.CENTER_ID,'02',t.BUSINESS_TRAFFIC,0)) 西公司, sum(decode(t.CENTER_ID,'03',t.BUSINESS_TRAFFIC,0)) 北公司, sum(decode(t.CENTER_ID,'04',t.BUSINESS_TRAFFIC,0)) 南公司, '08:30-09:00' from OM_MCMS_AUTHLOG_RT t where T.FINISHTIME between to_date((to_char(sysdate, 'yyyy-mm-dd') ||' 08:30:00'),'yyyy-mm-dd HH:mi:ss') and to_date((to_char(sysdate, 'yyyy-mm-dd') ||' 09:00:00'),'yyyy-mm-dd HH:mi:ss');