У меня есть таблица со следующими значениями в столбцах:
Таблица (col1, col2, col3, col4, col5, col6):
a b c d e f a b c g h i a b c k l m a b c n o p
В результате я хочу иметь одну строку:
a b c d e f g h i k l m n o p
Как это сделать?
Я бы использовал string_agg():
string_agg()
select string_agg(t.col, ' ') from (select col1 as col from t union select col2 from t union . . . select col6 from t ) t;
использовать union и string_agg
union
select string_agg(distinct c ,' ') from ( select col1 as c from t union select col2 from t union select col3 from t union select col4 from t union select col5 from t union select col6 from t ) as t1