From: | Douglas Nichols <dnichols(at)fhcrc(dot)org> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | sql question: min remapped value |
Date: | 1999-11-18 23:26:24 |
Message-ID: | 38348B20.6A4F8EF1@fhcrc.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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(at)fhcrc(dot)org
---------------------------------------------------------------
National Wilms Tumor Study Group 206.667.4283
Seattle, WA
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 1999-11-19 00:43:53 | Re: [SQL] sql question: min remapped value |
Previous Message | Jan Wieck | 1999-11-18 22:18:03 | Re: [SQL] Can't create an index on NUMERIC(x,y) |