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

From David G. Johnston
Subject Re: help with generation_series in pg10
Date
Msg-id CAKFQuwaHkjU47EHin7_7JRjvC1SL-pL=HvUyNVHepuLqRaLpwA@mail.gmail.com
Whole thread Raw
In response to Re: help with generation_series in pg10  (Adrian Klaver <adrian.klaver@aklaver.com>)
List pgsql-general
On Monday, January 8, 2018, Adrian Klaver <adrian.klaver@aklaver.com> wrote:

I am not seeing a solution, but you might see something that would help you.

There is no general solution.  For the problem at hand I would union two generate_series(1,5) queries with a query_id column.  Then I'd use row_number() over (order by query_id, series_num) to compute the column containing the values 1-10.

Alternatively, use the modulus operator (% 5) on 1-10 to generate the second column.

David J.

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: help with generation_series in pg10
Next
From: Agnar Renolen
Date:
Subject: Getting started with first user.