- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
select a, trim(both ',' from max(SYS_CONNECT_BY_PATH(b, ',')))bb from (
select count(1) over (partition by a order by /* Важно:*/ a,b /*!*/)rn, a, b from (
select a, b from (
select 1 a, 'a' b from dual union all
select 1 a, 'b' b from dual union all
select 2 a, 'c' b from dual union all
select 2 a, 'd' b from dual union all
select 2 a, 'e' b from dual union all
select 3 a, 'f' b from dual
) order by dbms_random.value
)
)
start with rn=1 connect by nocycle prior a=a and prior rn+1=rn
group by a;
Задача на агрегацию с конкатенацией строк. Можно решить правильно - через свой агрегирующий объект, а можно так, "не по правилам" ))