how to select custom value when exists otherwise select default - Mailing list pgsql-sql

From patrick
Subject how to select custom value when exists otherwise select default
Date
Msg-id 421133db$0$6585$8fcfb975@news.wanadoo.fr
Whole thread Raw
List pgsql-sql
I use a select like this:
SELECT sometables
WHERE field0='a' or field0='b' or field0='c'
and field4='m' or field4='n'
ORDER BY field0;

m.field4 is default value
n.field4 is custom value

I want only n(custom) if it exists ortherwise I want m(default)
but I do not want both!

I mean I have this result:
table{
field0 {a,a,b,c}
field1 {d,d,e,f}
field2 {g,g,h,i}
field3 {j,j,k,l}
field4 {m,n,m,m}
}
a.filed0 has 2 results, one for m(default) and one for n(optionnal)
b and c have no custom value so field4 is set to m for them

and I want this result:
table{
field0 {a,b,c}
field1 {d,e,f}
field2 {g,h,i}
field3 {j,k,l}
field4 {n,m,m}
}

of course I'm looking for only one request to do that, and I'd rather a
lighter one ;-)


pgsql-sql by date:

Previous
From: "Eugen Gass"
Date:
Subject: Trigger
Next
From: Shridhar Daithankar
Date:
Subject: Re: [GENERAL] How to view the list of tables?