17,086
社区成员
发帖
与我相关
我的任务
分享
with t as
(
select 'a' a, 'b' b, 'c' c from dual
union all
select 'a' a, 'b' b, 'd' c from dual
union all
select 'e' a, 'f' b, 'g' c from dual
union all
select 'e' a, 'f' b, 'h' c from dual
)
select a,b,wm_concat(c)
from t
group by a,b;
with t as
(
select 'a' a, 'b' b, 'c' c from dual
union all
select 'a' a, 'b' b, 'd' c from dual
union all
select 'e' a, 'f' b, 'g' c from dual
union all
select 'e' a, 'f' b, 'h' c from dual
)
select a,b,max(substr(sys_connect_by_path(c,','),2))
from
( select a,b,c,row_number() over(partition by a,b order by a) rn from t)
start with rn=1 connect by rn-1=prior rn and a=prior a
group by a,b
order by a,b
--result:
a b c,d
e f g,h