Re: [GENERAL] postgresql how to duplicate rows in result. - Mailing list pgsql-general

From Merlin Moncure
Subject Re: [GENERAL] postgresql how to duplicate rows in result.
Date
Msg-id CAHyXU0zGC7Xb=bKYBCAMitXk3Y8zBw2ztFTsqdNXL7fW23JwTw@mail.gmail.com
Whole thread Raw
In response to [GENERAL] postgresql how to duplicate rows in result.  (Alessandro Baggi <alessandro.baggi@gmail.com>)
Responses Re: [GENERAL] postgresql how to duplicate rows in result.  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-general
On Tue, Feb 14, 2017 at 12:04 PM, Alessandro Baggi
<alessandro.baggi@gmail.com> wrote:
> Hi list,
> sorry for my english, I will try to example as well. I've a query that joins
> multiple tables and return a result like:
>
> id,customers,phone,code,number
> 1 , aaaaaaaa,33333,123 , 2
> 2 , aassdsds,33322,211 , 1
> 3 , oooooooo,21221,221 , 1
>
>
> I need, where "number" field is > 1, to duplicate the row * N(number field
> value) with a result like this:
>
> id,customers,phone,code,number
> 1 , aaaaaaaa,33333,123 , 2
> 1 , aaaaaaaa,33333,123 , 2
> 2 , aassdsds,33322,211 , 1
> 3 , oooooooo,21221,221 , 1
>
> How I can accomplish to this problem?

SELECT * FROM foo CROSS JOIN LATERAL (1,number);

:-D

merlin


pgsql-general by date:

Previous
From: Melvin Davidson
Date:
Subject: Re: [GENERAL] postgresql how to duplicate rows in result.
Next
From: John McKown
Date:
Subject: Re: [GENERAL] postgresql how to duplicate rows in result.