我是靠谱客的博主 潇洒春天,这篇文章主要介绍oracle 合并结果集,oracle中如何处理结果集合并?,现在分享给大家,希望可以做个参考。

假设表的名字叫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内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(111)

评论列表共有 0 条评论

立即
投稿
返回
顶部