Reputation: 181
With Postgresql I have the query:
select '1' , '2', '3';
with result
I would like to have next result:
column
1
2
3
How can I do that?
Upvotes: 0
Views: 861
Reputation: 246288
I prefer to use a table function for that:
SELECT CAST(i AS text) FROM generate_series(1, 3) AS i;
Upvotes: 1
Reputation: 126991
You could create an array and then use UNNEST():
SELECT UNNEST(ARRAY[1,2,3]);
Upvotes: 2
Reputation: 46219
You are looking for Unpivot
, then you can try to use UNION ALL
select '1' column
UNION ALL
SELECT '2'
UNION ALL
SELECT '3'
or you can try to use JOIN LATERAL
SELECT s.*
FROM test t
JOIN LATERAL (VALUES(t.a),(t.b),(t.c)) s(column) ON TRUE
Upvotes: 1