|
partition by b
drop table test;
create table test(a number(10),b number(10));
insert into test values(&a,&b);
1
1
/
2
1
/
6
1
/
7
1
/
9
1
/
11
1
/
167
1
/
35432
1
/
7
1
/
9
1
/
11
2
/
167
2
/
35432
2
/
36436
3
/
37467
3
/
36732
3
commit;
rem select b.a+1 as start_no,b.next-1 as end_no from (select a, lead(a,1) over (order by a) as next from test) b where b.a+1<>b.next;
select b.a+1 as start_no,b.next-1 as end_no,b.b as gb_b from (select a, lead(a,1) over (partition by b order by a) as next,b from test) b where b.a+1<=b.next-1;
drop table test;
START_NO END_NO GB_B
---------- ---------- ----------
3 5 1
8 8 1
10 10 1
12 166 1
168 35431 1
12 166 2
168 35431 2
36437 36731 3
36733 37466 3 |
|