December 18th, 2003, 07:59 PM
return value from 3 fields into 1 field
I would like to be able to query a table which contains 3 fields with identical information and return the value from any of those fields based on a pecking order. The pecking order would be like this: field a, field b, field c. If field a contains data, the returned value would be the value of field a even if fields b & c contain data
since field a is highest in the pecking order. If field a contains no data, then the value of field b would be returned. The last check would be to return the data in field c if none was found in either a or b. Since I am lazy, I am looking for the simplest solution.
Thanks in advance for any help you can give me.
December 19th, 2003, 07:44 AM
assuming that "If field a contains no data" means null, this is the simplest solution:
select coalesce(fielda,fieldb,fieldc) from yourtable