Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id EAF0FB5DBDC for ; Tue, 23 Aug 2011 16:55:57 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 54501-05 for ; Tue, 23 Aug 2011 19:55:51 +0000 (UTC) X-Greylist: delayed 00:06:40.677275 by SQLgrey-1.7.6 Received: from mailout-de.gmx.net (mailout-de.gmx.net [213.165.64.22]) by mail.postgresql.org (Postfix) with SMTP id 85917B5D803 for ; Tue, 23 Aug 2011 16:55:50 -0300 (ADT) Received: (qmail invoked by alias); 23 Aug 2011 19:49:08 -0000 Received: from p57A5D812.dip.t-dialin.net (EHLO [192.168.1.113]) [87.165.216.18] by mail.gmx.net (mp054) with SMTP; 23 Aug 2011 21:49:08 +0200 X-Authenticated: #14269776 X-Provags-ID: V01U2FsdGVkX1/lBF90o1DlyJ98NedqxEt3ES/71/vZHhFGMiA5tD hgKjK/Q7E3E9jp Message-ID: <4E540434.2000603@gmx.net> Date: Tue, 23 Aug 2011 21:49:08 +0200 From: Andreas User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0) Gecko/20110812 Thunderbird/6.0 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: need magic to shuffle some numbers Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.394 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RP_MATCHES_RCVD=-0.505, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201108/97 X-Sequence-Number: 35765 Hi, there is a table that has among others a integer primary key "id" and another integer column "prio" as well as an integer "group_id". I'd like to invert the values of the prio-column for one of the groups. The prio numbers start with 3 and there are 1159 different prios in this group. At least every value appeares only once. :) Is there an elegant way to switch the prio values around so that every record with the first prio gehts the last and vice versa? Then the records with the second smallest prio get the second-to-last biggest value and v.v. ... regards