when I execute following query.
select 30,60,90,120,150,180 from table
I get output given below
But my desire output like, Want out in only one column.
sequence 30 60 90 120 150 180
Is this possible?
Use UNION ALL
that will work in all major RDBMSes
SELECT 30 "sequence" UNION ALL
SELECT 60 UNION ALL
SELECT 90 UNION ALL
SELECT 120 UNION ALL
SELECT 150 UNION ALL
SELECT 180
or use postgres' generate_series()
function
SELECT *
FROM generate_series(30, 180, 30) "sequence";
Output:
| SEQUENCE | |----------| | 30 | | 60 | | 90 | | 120 | | 150 | | 180 |
Here is SQLFIddle demo for both queries
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With