Ljubiša Borojević
Ljubiša Borojević

Reputation: 11

How to create data serie in Postgresql without function generate_series

I need to create data series with the value from 0 to 100 with a step of 0.1 Unfortunately, function generate_series() does not work with my database. does anyone know any other way to create a series like this? Thank you in advance.

Upvotes: 0

Views: 184

Answers (1)

Lukasz Szozda
Lukasz Szozda

Reputation: 175726

One way is to use recursive cte:

WITH RECURSIVE CTE(c) AS (
  VALUES (0.0)
  UNION ALL
  SELECT c + 0.1
  FROM cte
  WHERE c <= 100
)
SELECT *
FROM CTE;

db<>fiddle demo

Upvotes: 2

Related Questions