日期:2014-05-17 浏览次数:21115 次
with t1 as
(select t.custid,
(t.day - lag(t.day) over(partition by t.custid order by day)) * 24 * 60 * 60 lday,
count(1) over(partition by custid) cnt
from tb_submit t
where t.submit = 'err')
select *
from tb_submit t
where exists (select 1
from t1
where t.custid = t1.custid
and t1.lday <= 10
and t1.cnt = 2)
and t.submit = 'err';
with t1 as
(
select 1 keyid,1 custid,'err' submit,to_date('2013-05-01 11:00:01','yyyy-mm-dd hh24:mi:ss') tdate from dual union all
select 2 keyid,1 custid,'ok' submit,to_date('2013-05-01 11:00:03','yyyy-mm-dd hh24:mi:ss') tdate from dual union all
select 3 keyid,1 custid,'err' submit,to_date('2013-05-01 11:00:04','yyyy-mm-dd hh24:mi:ss') tdate from dual union all
select 4 keyid,2 custid,'err' submit,to_date('2013-05-01 11:00:01','yyyy-mm-dd hh24:mi:ss') tdate from dual union all
select 5 keyid,2 custid,'ok' submit,to_date('2013-05-01 11:00:03','yyyy-mm-dd hh24:mi:ss') tdate from dual union all
select 6 keyid,2 custid,'err' submit,to_date('2013-05-01 11:00:02','yyyy-mm-dd hh24:mi:ss') tdate from dual union all
select 7 keyid,3 custid,'err' submit,to_date('2013-05-01 11:00:01','yyyy-mm-dd hh24:mi:ss') tdate from dual u