Posted on 10th September 2024|46 views
How to generate series in PostgreSQL?
Posted on 10th September 2024| views
The [start],[stop] will generate and stop series and [increment] is used to increment the sequence by that value.
Syntax:
generate_series([start], [stop], [intervel/increment]);
Generate series in PostgreSQL can be used to build a set in column-wise with a regular incrementation as provided in the syntax.
For example:
SELECT * FROM generate_series(1[start], 15[Stop], 2[Increment]);
Now you run SQL you get,
OUTPUT:
1
3
5
7
9
11
13
15