Re: Update ordered

Поиск
Список
Период
Сортировка
От Andreas Joseph Krogh
Тема Re: Update ordered
Дата
Msg-id OfficeNetEmail.22.db4f408b1acc02b2.143d43670c9@prod2
обсуждение исходный текст
Ответ на Re: Update ordered  (Adrian Klaver <adrian.klaver@gmail.com>)
Ответы Re: Update ordered  (Adrian Klaver <adrian.klaver@gmail.com>)
Список pgsql-sql
På mandag 27. januar 2014 kl. 15:56:12, skrev Adrian Klaver <adrian.klaver@gmail.com>:
On 01/27/2014 06:36 AM, Andreas Joseph Krogh wrote:
> 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?

That would seem to depend on what get_next_project_number() does, the
contents of which are unknown.
 
get_next_project_number() gets the next project-number based on some custom logic.
 
What would be the best way to update all project's project-number having the oldes project get the first number returned by get_next_project_number() etc.?
 
Thanks.
 
--
Andreas Joseph Krogh <andreak@officenet.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
 

В списке pgsql-sql по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Update ordered
Следующее
От: Herouth Maoz
Дата:
Сообщение: How to insert rows distributed evenly between referenced rows?