Postgresql Range data types (odd , even , mix) ranges

84 Views Asked by At

Wondering if there is any option of using build in range data types to create ranges odd or even or mixed something like range(lower-bound,upper-bound, step) but with Built-in Range Types so i can use the range operators.

Right now im building arrays like below but would like to understand if somehow the built in range types can hold this sort of ranges under the wood.

SELECT
ARRAY (SELECT arr FROM 
        generate_series(1, 10, CASE WHEN 1 in (1,2) THEN 2 ELSE 1 END) arr
        ) as data_range;

data_range -> "{1,3,5,7,9}"

0

There are 0 best solutions below