Search Postgresql Archives

Re: how to duplicate data for few times by SQL command in PG

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 22/01/2015 15:37, tsunghan hsieh wrote:
> Hi
> 
> I have a table which just has one column as following in Original Table.
> I wanna duplicate all of data for few times and with same order as
> following in New Table. Is there anyone who can help me? Thanks

How about something like this? -

	insert into <new table>
	select <whatever> from <original table>
	cross join generate_series(1, 3)
	order by <whatever>

This assumes that you want each item duplicated the same number of times.

Hope this helps,

Ray.

-- 
Raymond O'Donnell :: Galway :: Ireland
rod@xxxxxx


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux