Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eZICm-000857-0y for pgsql-general@arkaria.postgresql.org; Wed, 10 Jan 2018 15:22:16 +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 1eZICl-0008GE-D5 for pgsql-general@arkaria.postgresql.org; Wed, 10 Jan 2018 15:22:15 +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 1eZICl-0008Fx-26 for pgsql-general@lists.postgresql.org; Wed, 10 Jan 2018 15:22:15 +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 1eZICg-0005c3-Tk for pgsql-general@postgresql.org; Wed, 10 Jan 2018 15:22:13 +0000 Received: from MarcioPC (unknown [186.226.37.77]) (Authenticated sender: marcio@zyontecnologia.com.br) by cafe.concordia.psi.br (Postfix) with ESMTPA id A734F1000F26; Wed, 10 Jan 2018 13:22:05 -0200 (BRST) From: =?UTF-8?Q?M=C3=A1rcio_A._Sepp?= To: "'Merlin Moncure'" Cc: "'Alvaro Herrera'" , "'pgsql-general'" References: <00bb01d388e8$c9607b50$5c2171f0$@com.br> <20180109100125.65ws2rpygq6az4eo@alvherre.pgsql> <00ee01d38964$f7bfbf70$e73f3e50$@com.br> In-Reply-To: Subject: RES: help with generation_series in pg10 Date: Wed, 10 Jan 2018 13:22:07 -0200 Message-ID: <005801d38a26$c7068540$55138fc0$@com.br> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AdOKH1NMO+gjuHBGRyOmIK8T4DwTAwABu8CQ Content-Language: pt-br 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'); > > 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!!!