Update ordered

From: Andreas Joseph Krogh <andreak(at)officenet(dot)no>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Update ordered
Date: 2014-01-27 14:36:10
Message-ID: OfficeNetEmail.16.5201e94b04d2ffbf.143d41efaac@prod2
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi all.   I want an UPDATE query to update my project's project_number in
chronological order (according to the project's "created"-column) and tried
this:   with upd as(
    select id from project order by created asc
) update project p set project_number = get_next_project_number() from upd
where upd.id = p.id;   However, the olders project doesn't get the smalles
project_number.   Any idea how to achive this?   Thanks.   --
Andreas Joseph Krogh <andreak(at)officenet(dot)no>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Adrian Klaver 2014-01-27 14:56:12 Re: Update ordered
Previous Message Glyn Astill 2014-01-27 11:00:51 Re: Trigger function - variable for schema name