Received: from fhcrc.org (bug3.fhcrc.org [140.107.10.112]) by hub.org (8.9.3/8.9.3) with ESMTP id SAA81701 for ; Thu, 18 Nov 1999 18:35:12 -0500 (EST) (envelope-from dnichols@fhcrc.org) Received: from snap.fhcrc.org (snap [140.107.49.11]) by fhcrc.org (8.9.3/8.9.3) with ESMTP id PAA10453 for ; Thu, 18 Nov 1999 15:35:10 -0800 (PST) Received: from fhcrc.org (IDENT:dnichols@slip166-72-212-97.mo.us.prserv.net [166.72.212.97]) by snap.fhcrc.org (8.9.3/8.9.1) with ESMTP id PAA18795 for ; Thu, 18 Nov 1999 15:34:57 -0800 (PST) Sender: dnichols@snap.fhcrc.org Message-ID: <38348B20.6A4F8EF1@fhcrc.org> Date: Thu, 18 Nov 1999 23:26:24 +0000 From: Douglas Nichols Organization: National Wilms Tumor Study Group X-Mailer: Mozilla 4.7 [en] (X11; U; Linux 2.2.5-15 i686) X-Accept-Language: en, fr, nl-BE, ga, it, ja MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: sql question: min remapped value Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I am trying to remap a field find the row with the minimum value and then keep the original value and the id number from that row something like this: mydata (id, field1) field1 can = 0,1,2,3,4,5 but I reallt need them ordered like this (1=2, 0=2, 3=4, 4=5, 5=0) once I find the lowest remapped value I need to know id & field1 I was looking at something like select id, field1, min(decode(field1,1,1,0,2,3,4,4,5,0)) as flag from mydata group by id; Any help is appreciated and thanks ahead! Cheers, dn Douglas Nichols dnichols@fhcrc.org --------------------------------------------------------------- National Wilms Tumor Study Group 206.667.4283 Seattle, WA