假设表的名字叫T_CONNECT
select min(startno) || '~' || max(endno), count(*)
from (
-- 查出号码连续记录段的第一个号码
select t.*, CONNECT_BY_ROOT(startno) rootno
from t_connect t
start with startno in (
--查出不连续号码的第一条记录,作为递归查询的初始条件
select startno
from (
select startno, endno, lag(endno) over (order by startno) prev_endno
from t_connect t
order by startno
)
where (startno <> prev_endno + 1) or prev_endno is null
)
connect by prior endno + 1 = startno
)
group by rootno
order by rootno
最后
以上就是潇洒春天最近收集整理的关于oracle 合并结果集,oracle中如何处理结果集合并?的全部内容,更多相关oracle内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复