Search Postgresql Archives

Reordering a table

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

 



Hi,

a puzzle to solve...

I have a table with a primary key, and a timestamp, e.g.

id    stamp
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:

id    stamp
1     2011-02-01 09:00
2     2011-02-01 10:00
3     2011-02-01 11:00

I thought I could do it by adding a third colum with the order in it, but I cannot think of a way to do this short of writing some code

id    stamp                         order
1     2011-02-01 10:00    2
2     2011-02-01 09:00    1
3     2011-02-01 11:00    3

Any ideas?

Thanks.
Howard
www.selestial.com

--
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