On 22/02/2011 5:18 PM, Vibhor Kumar wrote:
If you are using PG 8.4 then you can try something with row_number as
given below:
select id,stamp, row_number() over(order by stamp) from test;
Or
Create table test1 as select row_number() over(order by stamp) as id, stamp
from test;
Thanks& Reg
ilto:pgsql-general-ow...@postgresql.org] On Behalf Of Howard Cole
Sent: Tuesday, February 22, 2011 11:41 AM
To: pgsql-general@postgresql.org
Subject: [GENERAL] Reordering a table
Hi,
a puzzle to solve...
I have a table with a primary key, and a timestamp, e.g.
idstamp
1 2011-02-01 10:00
On Feb 22, 2011, at 10:10 PM, Howard Cole wrote:
> Hi,
>
> a puzzle to solve...
>
> I have a table with a primary key, and a timestamp, e.g.
>
> idstamp
> 1 2011-02-01 10:00
> 2 2011-02-01 09:00
> 3 2011-02-01 11:00
>
> Now for reasons too painful to go into, I need to reorder
On Tue, Feb 22, 2011 at 04:40:36PM +, Howard Cole wrote:
- Hi,
-
- a puzzle to solve...
-
- I have a table with a primary key, and a timestamp, e.g.
-
- idstamp
- 1 2011-02-01 10:00
- 2 2011-02-01 09:00
- 3 2011-02-01 11:00
-
- Now for reasons too painful to go into, I need
Hi,
a puzzle to solve...
I have a table with a primary key, and a timestamp, e.g.
idstamp
1 2011-02-01 10:00
2 2011-02-01 09:00
3 2011-02-01 11:00
Now for reasons too painful to go into, I need to reorder the id
(sequence) so that they are in time order:
idstamp
1 20