Re: help with generation_series in pg10 - Mailing list pgsql-general

From Vincenzo Romano
Subject Re: help with generation_series in pg10
Date
Msg-id CAHjZ2x5KZVz0Wdznw49P1EmwRjMkOFzL=Ob=LFdZ+mNE90rFeQ@mail.gmail.com
Whole thread Raw
In response to Re: help with generation_series in pg10  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
List pgsql-general
2018-01-09 11:01 GMT+01:00 Alvaro Herrera <alvherre@alvh.no-ip.org>:
> Márcio A. Sepp wrote:
>
>> how can i have the same in pg10 as i have had in pg 9.x?
>
> Move the function call to the FROM clause:
>
> select g, (g - 1) % 5 + 1 from generate_series(1, 10) g;
>
>> I need it to date type to...  if possible.
>
> There is a generate_series() variant that can return dates (more
> precisely, timestamp with time zone).  But what exactly would you like
> returned?
>
> --
> Álvaro Herrera                https://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>

You can add a generated series as seconds, minutes, hours ... to a
base timestamp.
Yes, it's not an easy going expression, but I'd do it like this.

--
Vincenzo Romano - NotOrAnd.IT
Information Technologies
--
NON QVIETIS MARIBVS NAVTA PERITVS


pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: help with generation_series in pg10
Next
From: Andreas Joseph Krogh
Date:
Subject: Sv: Re: [GENERAL] pg_dump streaming fails - PostgreSQL 9.2