时间:
select * from mread.sup_operatelog a where a.stepid = '040110' and a.operatetime > to_date('20160525 13:09', 'yyyymmdd hh24:mi') and a.operatetime < to_date('20160525 13:15', 'yyyymmdd hh24:mi') order by operatetime desc
instr (sourceString,destString,start,appearPosition)
instr('源字符串' , '目标字符串' ,'开始位置','第几次出现')
substr ( string, start_position, [ length ] )
substr ('目标字符串',开始位置,长度)
REPLACE(str,from_str,to_str)
———— to_str 不写表示空、null
例子
select replace(substr(a.operateobject, 1, instr(a.operateobject, '|', 1, 1) - 1), '书ID:') bookid, replace(substr(a.operateobject, instr(a.operateobject, '|', 1, 4), instr(a.operateobject, '|', 1, 5) - instr(a.operateobject, '|', 1, 4) - 1), '|章节ID:') mcpchapterid, replace(substr(a.operateobject, instr(a.operateobject, '|', 1, 6), instr(a.operateobject, '|', 1, 7) - instr(a.operateobject, '|', 1, 6) - 1), '|请求时间:') reqtime from mread.sup_operatelog a where a.stepid = '040110' and a.operatetime > to_date('20160520 3:09', 'yyyymmdd hh24:mi') and a.operatetime < to_date('20160520 13:15', 'yyyymmdd hh24:mi') and substr(a.operateobject, instr(a.operateobject, '|', 1, 10) + 1, instr(a.operateobject, '|', 1, 11) - instr(a.operateobject, '|', 1, 10) - 1) = '处理结果返回码:0'
case
select case when a.operatetime < to_date('20160525 13:10', 'yyyymmdd hh24:mi') then 1 else 2 end, count(*) from mread.sup_operatelog a where a.operatetime > to_date('20160525 13:09', 'yyyymmdd hh24:mi') and a.operatetime < to_date('20160525 13:15', 'yyyymmdd hh24:mi') group by case when a.operatetime < to_date('20160525 13:10', 'yyyymmdd hh24:mi') then 1 else 2 end select case when op_date <= 60 then 1 when op_date > 60 and op_date <= 120 then 2 when op_date > 120 and op_date <= 600 then 3 else 4 end, count(*) from cfgbk.gc0524_sup_operatelog group by case when op_date <= 60 then 1 when op_date > 60 and op_date <= 120 then 2 when op_date > 120 and op_date <= 600 then 3 else 4 end;
时间差 换算:
select trunc(sysdate, 'mi'), a.implicitcreatetime, (trunc(sysdate, 'mi') - a.implicitcreatetime) * 60 * 60 * 24 op_date from cntdb.CON_T_BASECHAPTER a where a.implicitcreatetime > to_date('20160526 16:09', 'yyyymmdd hh24:mi') and a.implicitcreatetime < to_date('20160526 16:15', 'yyyymmdd hh24:mi')