Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eYwax-0000yL-Hf for pgsql-general@arkaria.postgresql.org; Tue, 09 Jan 2018 16:17:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eYwax-0002dU-2w for pgsql-general@arkaria.postgresql.org; Tue, 09 Jan 2018 16:17:47 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eYwY8-0004cy-WC for pgsql-general@lists.postgresql.org; Tue, 09 Jan 2018 16:14:53 +0000 Received: from cafe.concordia.psi.br ([189.91.194.2]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eYwY5-0000Ni-Gt for pgsql-general@postgresql.org; Tue, 09 Jan 2018 16:14:51 +0000 Received: from MarcioPC (unknown [186.226.37.77]) (Authenticated sender: marcio@zyontecnologia.com.br) by cafe.concordia.psi.br (Postfix) with ESMTPA id A0DD2101E4CD; Tue, 9 Jan 2018 14:14:45 -0200 (BRST) From: =?iso-8859-1?Q?M=E1rcio_A._Sepp?= To: "'Alvaro Herrera'" Cc: "'pgsql-general'" References: <00bb01d388e8$c9607b50$5c2171f0$@com.br> <20180109100125.65ws2rpygq6az4eo@alvherre.pgsql> In-Reply-To: <20180109100125.65ws2rpygq6az4eo@alvherre.pgsql> Subject: RES: help with generation_series in pg10 Date: Tue, 9 Jan 2018 14:14:46 -0200 Message-ID: <00ee01d38964$f7bfbf70$e73f3e50$@com.br> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Content-Language: pt-br Thread-Index: AdOJMObzQYE+iL5ASKW9fr40mXlUAwAMX8+Q List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > > 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