postgresql how to duplicate rows in result.

From: Alessandro Baggi <alessandro(dot)baggi(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: postgresql how to duplicate rows in result.
Date: 2017-02-14 18:04:09
Message-ID: 508453e6-af91-c626-ad76-ea65737c27d9@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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?

I'm using postgresql 9.3.15.

thanks in advance.

Alessandro.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2017-02-14 18:06:21 Re: database folder name and tables filenames
Previous Message Mimiko 2017-02-14 17:47:00 Re: database folder name and tables filenames