pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Márcio A. Sepp <marcio@zyontecnologia.com.br>
To: 'Alvaro Herrera' <alvherre@alvh.no-ip.org>
Cc: 'pgsql-general' <pgsql-general@postgresql.org>
Subject: RES: help with generation_series in pg10
Date: Tue, 9 Jan 2018 14:14:46 -0200
Message-ID: <00ee01d38964$f7bfbf70$e73f3e50$@com.br> (raw)
In-Reply-To: <20180109100125.65ws2rpygq6az4eo@alvherre.pgsql>
References: <00bb01d388e8$c9607b50$5c2171f0$@com.br>
	<20180109100125.65ws2rpygq6az4eo@alvherre.pgsql>


> > 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');


in some case I need to order the timestamp data field and in others I just
need an interval. So, in some moments an random data already help me and in
others it is necessary to have both fields aligned.


thanks





view thread (3+ messages)  latest in thread

Message-ID: <00ee01d38964$f7bfbf70$e73f3e50$@com.br>
Permalink:  ../00ee01d38964$f7bfbf70$e73f3e50$@com.br/
Also on:    postgresql.org/message-id/00ee01d38964$f7bfbf70$e73f3e50$@com.br

 · 

reply

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, alvherre@alvh.no-ip.org
  Subject: Re: help with generation_series in pg10
  In-Reply-To: <00ee01d38964$f7bfbf70$e73f3e50$@com.br>
  References: <00bb01d388e8$c9607b50$5c2171f0$@com.br> <20180109100125.65ws2rpygq6az4eo@alvherre.pgsql> <00ee01d38964$f7bfbf70$e73f3e50$@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