Douglas Nichols <dnichols@fhcrc.org> writes:
> 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;
Postgres doesn't have DECODE (nor is it in the SQL standard), but
you can get the effect you want with a CASE expression. Note that
CASE is rather buggy in pre-6.5.2 releases, so update if you haven't
lately.
PS: you won't be able to access field1 outside the MIN() if you have
"group by id" as shown.
regards, tom lane