with aaa as (select 'aaa' 单位 ,'20100101' 日期,'A'票符 , 1 起号 , 3 至号 from dual union all select 'aaa','20100101','A' ,4, 8 from dual union all select 'bbb','20100102','B' ,1, 9 from dual union all select 'bbb','20100102','B' ,4, 20 from dual union all select 'ddd','20100103','C' ,12, 19 from dual union all select 'ddd','20100103','C' ,22, 40 from dual), b as ( select a.单位,a.日期,a.票符,level ,CONNECT_BY_ROOT a.起号 起号,a.至号 至号,CONNECT_BY_ISLEAF leaf from aaa a start with not exists (select 'X' from aaa a2 where a2.票符=a.票符 and a2.至号=a.起号-1 ) connect by prior a.票符=a.票符 and prior a.至号+1=a.起号 ) select b.单位,b.日期,b.票符,min(b.起号),b.至号 from b where b.leaf=1 group by b.票符,b.至号,b.单位,b.日期我是要实现这样一个功能,但是在net中执行后跟踪调试没有数据读出?
(select 'aaa' 单位 ,'20100101' 日期,'A'票符 , 1 起号 , 3 至号 from dual union all
select 'aaa','20100101','A' ,4, 8 from dual union all
select 'bbb','20100102','B' ,1, 9 from dual union all
select 'bbb','20100102','B' ,4, 20 from dual union all
select 'ddd','20100103','C' ,12, 19 from dual union all
select 'ddd','20100103','C' ,22, 40 from dual),
b as (
select a.单位,a.日期,a.票符,level ,CONNECT_BY_ROOT a.起号 起号,a.至号 至号,CONNECT_BY_ISLEAF leaf
from aaa a
start with not exists (select 'X'
from aaa a2
where a2.票符=a.票符
and a2.至号=a.起号-1
)
connect by prior a.票符=a.票符
and prior a.至号+1=a.起号
)
select b.单位,b.日期,b.票符,min(b.起号),b.至号
from b
where b.leaf=1
group by b.票符,b.至号,b.单位,b.日期我是要实现这样一个功能,但是在net中执行后跟踪调试没有数据读出?