From: Márcio A. Sepp <marcio@zyontecnologia.com.br>
To: 'Merlin Moncure' <mmoncure@gmail.com>
Cc: 'Alvaro Herrera' <alvherre@alvh.no-ip.org>
Cc: 'pgsql-general' <pgsql-general@postgresql.org>
Subject: RES: help with generation_series in pg10
Date: Wed, 10 Jan 2018 13:22:07 -0200
Message-ID: <005801d38a26$c7068540$55138fc0$@com.br> (raw)
In-Reply-To: <CAHyXU0wh0bt-8QAjHHdH+SQQ4WdvVGWS8hT6deZMqXfenCYb-Q@mail.gmail.com>
References: <00bb01d388e8$c9607b50$5c2171f0$@com.br>
<20180109100125.65ws2rpygq6az4eo@alvherre.pgsql>
<00ee01d38964$f7bfbf70$e73f3e50$@com.br>
<CAHyXU0wh0bt-8QAjHHdH+SQQ4WdvVGWS8hT6deZMqXfenCYb-Q@mail.gmail.com>
> >> > 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;
> >
> > thank you. That is exact what i need.
> >
> >
> >> > 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?
> >
> > In the past i use querys like this to generate some timestamp field:
> > select generate_series (1, 10), generate_series('2018-01-01
> > 10:00'::timestamp, '2018-01-02 10:00'::timestamp, '10 hours');
>
> With the old behavior you're lucky this ever worked at all. Doing this
> kind of stuff, you want to write it with a single generate_series
> driver if you can or as a cross product:
>
> select
> a, b,c
> from generate_series(1,3) a
> cross join generate_series(1,4) b
> cross join generate_series(1,2) c;
Exactly what I need. Thank you so much!!!
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: marcio@zyontecnologia.com.br, mmoncure@gmail.com, alvherre@alvh.no-ip.org
Subject: Re: help with generation_series in pg10
In-Reply-To: <005801d38a26$c7068540$55138fc0$@com.br>
References: <00bb01d388e8$c9607b50$5c2171f0$@com.br> <20180109100125.65ws2rpygq6az4eo@alvherre.pgsql> <00ee01d38964$f7bfbf70$e73f3e50$@com.br> <CAHyXU0wh0bt-8QAjHHdH+SQQ4WdvVGWS8hT6deZMqXfenCYb-Q@mail.gmail.com> <005801d38a26$c7068540$55138fc0$@com.br>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox