Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W7nc1-0006YY-OD for pgsql-sql@arkaria.postgresql.org; Mon, 27 Jan 2014 14:56:34 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W7nc0-0000fc-Er for pgsql-sql@arkaria.postgresql.org; Mon, 27 Jan 2014 14:56:32 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W7nbz-0000eb-BZ for pgsql-sql@postgresql.org; Mon, 27 Jan 2014 14:56:31 +0000 Received: from mail-pa0-f52.google.com ([209.85.220.52]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W7nbs-00039Q-Lf for pgsql-sql@postgresql.org; Mon, 27 Jan 2014 14:56:30 +0000 Received: by mail-pa0-f52.google.com with SMTP id bj1so5987354pad.39 for ; Mon, 27 Jan 2014 06:56:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=9TtelMlorStMGA6pKaQ4cVbNdoU3Pke+/VUhC6Qqi6E=; b=0R68hJhEJ8SpfAw7GCbu5tCUmQKoujUs0yn9XxBWM3edY+m9aI0Zck0od6LMoN+1rb TrRM1WqpkATy1s5QbfQI9UEsxW6L+SEKNmF3coaC3Hlne1xbywGknLAgumCQgWsrdXui 8SL0vl7CxFVYq45Wld3PRMmohExztShypC1JzfiiHbTUKleexaToiEYU5uqoQqs+8Kfr PmFX71O7SEw79geaA2dxh5Dxm7rmWEWrFydihMU3NnjOKuzmtcTK4ullJwBULEvlMEJg 2fHtOU+Mxa0BayEf1oY02VMhQDDoCa8Rkwu/YtEEAZ+cKBoCHuZd6eYwFX+AUxA4G5CO G0Jw== X-Received: by 10.68.226.70 with SMTP id rq6mr30707932pbc.107.1390834576079; Mon, 27 Jan 2014 06:56:16 -0800 (PST) Received: from panda.site (65-102-185-39.tukw.qwest.net. [65.102.185.39]) by mx.google.com with ESMTPSA id bc4sm32716397pbb.2.2014.01.27.06.56.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 27 Jan 2014 06:56:15 -0800 (PST) Message-ID: <52E6738C.7010101@gmail.com> Date: Mon, 27 Jan 2014 06:56:12 -0800 From: Adrian Klaver User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Andreas Joseph Krogh , "pgsql-sql@postgresql.org" Subject: Re: Update ordered References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org 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. > Thanks. > -- > Andreas Joseph Krogh 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 -- Adrian Klaver adrian.klaver@gmail.com -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql