Yuri Kaszubowski Lopes
Yuri Kaszubowski Lopes

Reputation: 583

Make a range in postgres

How can I make a range in a select in PostgreSQL? I'd like to have this result:

num
---
1
2
3
4
5
6

From a query like:

SELECT range(1,6) AS num;

Upvotes: 46

Views: 34952

Answers (1)

Quassnoi
Quassnoi

Reputation: 425371

SELECT  *
FROM    generate_series(1, 6) num

https://www.postgresql.org/docs/current/functions-srf.html

Upvotes: 92

Related Questions