|
|
with t as
(select 2014 id,
00000001 shuzi
from dual
union all
select 2014,
00000002
from dual
union all
select 2014,
00000003
from dual
union all
select 2014,
00000004
from dual
union all
select 2014,
00000005
from dual
union all
select 2014,
00000007
from dual
union all
select 2014,
00000008
from dual
union all
select 2014,
00000009
from dual
union all
select 2013,
00000120
from dual
union all
select 2013,
00000121
from dual
union all
select 2013,
00000122
from dual
union all
select 2013,
00000124
from dual
union all
select 2013,
00000125
from dual)
select * from
(select ttt.*,row_number()over(partition by id,da,xiao order by rownum)rw from (select id,
max(shuzi) over(partition by fen) da,
min(shuzi) over(partition by fen) xiao
from (select id,
shuzi,
sum(pai) over(order by rownum) fen
from (select id,
shuzi,
(case
when abs(lag(shuzi) over(order by rownum) - shuzi) = 1 then
0
else
1
end) pai
from t) tt))ttt) where rw=1
|
|