DB/Postgres
Postgresql 쉼표로 구분된 열을 행으로 변환
로아_
2023. 3. 29. 10:33
728x90
Postgresql 콤마로 구분된 데이터 열을 행으로 변환
SQL
with temp01 as (
select 1 as idx
, '가,나,다' as col01
union
select 2 as idx
, '라,마,바' as col01
)
select idx,
unnest(string_to_array(col01, ',')) as col01
from temp01
order by idx asc;
출처 : https://medium.com/swlh/three-routes-convert-comma-separated-column-to-rows-c17c85079ecf
728x90