Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W7nKV-0005pQ-IR for pgsql-sql@arkaria.postgresql.org; Mon, 27 Jan 2014 14:38:27 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W7nKU-0007bt-UX for pgsql-sql@arkaria.postgresql.org; Mon, 27 Jan 2014 14:38:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W7nKT-0007Zt-4z for pgsql-sql@postgresql.org; Mon, 27 Jan 2014 14:38:25 +0000 Received: from prod2.officenet.no ([195.159.87.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W7nKM-0004vW-As for pgsql-sql@postgresql.org; Mon, 27 Jan 2014 14:38:24 +0000 Received: from localhost ([127.0.0.1] helo=prod2) by prod2.officenet.no with esmtp (Exim 4.76) (envelope-from ) id 1W7nIJ-0007pi-5w for pgsql-sql@postgresql.org; Mon, 27 Jan 2014 15:36:11 +0100 Date: Mon, 27 Jan 2014 15:36:10 +0100 (CET) From: Andreas Joseph Krogh To: "pgsql-sql@postgresql.org" Message-ID: Subject: Update ordered MIME-Version: 1.0 X-Mailer: OfficeNet Mail 1.9.0-SNAPSHOT X-Pg-Spam-Score: -2.4 (--) Content-Type: multipart/alternative; boundary="----=_Part_52_62322539.1390833370581" 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 ------=_Part_50_742455410.1390833370543 Content-Type: multipart/related; boundary="----=_Part_51_1568086800.1390833370543" ------=_Part_51_1568086800.1390833370543 Content-Type: multipart/alternative; boundary="----=_Part_52_62322539.1390833370581" ------=_Part_52_62322539.1390833370581 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi all. =C2=A0 I want an UPDATE query to update my project's project_number= in=20 chronological order (according to the project's "created"-column) and tried= =20 this: =C2=A0 with upd as( =C2=A0=C2=A0=C2=A0 select id from project order by created asc ) update project p set project_number =3D get_next_project_number() from u= pd=20 where upd.id =3D p.id; =C2=A0 However, the olders project doesn't get the s= malles=20 project_number. =C2=A0 Any idea how to achive this? =C2=A0 Thanks. =C2=A0 -= - Andreas Joseph Krogh =C2=A0 =C2=A0 =C2=A0 mob: +47 9= 09 56 963 Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no Public key: http://home.officenet.no/~andreak/public_key.asc ------=_Part_52_62322539.1390833370581 Content-Type: text/html;charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi all.
=C2=A0
I want an UPDATE query to update my project's project_number in chrono= logical order (according to the project's "created"-column) and t= ried this:
=C2=A0
with upd as(
=C2=A0=C2=A0=C2=A0 select id from project order by created asc
) update project p set project_number =3D get_next_project_number() from up= d where upd.id =3D p.id;
=C2=A0
However, the olders project doesn't get the smalles project_number.
=C2=A0
Any idea how to achive this?
=C2=A0
Thanks.
=C2=A0
--
Andreas Joseph Krogh <andreak@officenet.no>=C2=A0 =C2=A0 =C2=A0 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
------=_Part_52_62322539.1390833370581-- ------=_Part_51_1568086800.1390833370543-- ------=_Part_50_742455410.1390833370543--