Самый простой способ - поместить их в один столбец, используя list_agg()
:
select col1, listagg(col2, ' ') within group (order by col2) as col2s
from t
group by col1;
. Для отдельных столбцов я бы рекомендовал row_number()
и условное агрегирование:
select col1,
max(case when seqnum = 1 then col2 end) as col2_1,
max(case when seqnum = 2 then col2 end) as col2_2,
max(case when seqnum = 3 then col2 end) as col2_3
from (select t.*, row_number() over (partition by col1 order by col2) as seqnum
from t
) t
group by col1;