17,140
社区成员




with tb as(
select 1 as id,'0703' as time,'a' as code from dual union all
select 1,'0702','a' from dual union all
select 1,'0701','b' from dual union all
select 1,'0630','a' from dual union all
select 2,'0703','a' from dual union all
select 2,'0702','a' from dual union all
select 2,'0701','a' from dual union all
select 2,'0630','b' from dual union all
select 2,'0629','b' from dual union all
select 2,'0628','c' from dual)
select id,time,code from(
select id,time,code,(select min(time) from tb where a.id=id and a.time<time )a from tb a
)a
where nvl((select code from tb where id=a.id and a=time),'$')!=code