La location
string è simile a un array di testo. Convertilo in text[]
e disannida:
with my_data(id, location) as (
values
(1, '["Humboldt, TN","Medina, TN","Milan, TN"]')
)
select id, unnest(format('{%s}', trim(location, '[]'))::text[]) as location
from my_data
id | location
----+--------------
1 | Humboldt, TN
1 | Medina, TN
1 | Milan, TN
(3 rows)
O ancora più semplice, esegui il cast della stringa su jsonb
e usa jsonb_array_elements_text()
:
with my_data(id, location) as (
values
(1, '["Humboldt, TN","Medina, TN","Milan, TN"]')
)
select id, jsonb_array_elements_text(location::jsonb) as location
from my_data