सामान्य तौर पर, के लिए एक विकल्प case when ...है coalesce(nullif(x,bad_value),y)(कि ओपी के मामले में इस्तेमाल नहीं किया जा सकता है)। उदाहरण के लिए,
select coalesce(nullif(y,''),x), coalesce(nullif(x,''),y), *
from ( (select 'abc' as x, '' as y)
union all (select 'def' as x, 'ghi' as y)
union all (select '' as x, 'jkl' as y)
union all (select null as x, 'mno' as y)
union all (select 'pqr' as x, null as y)
) q
देता है:
coalesce | coalesce | x | y
abc | abc | abc |
ghi | def | def | ghi
jkl | jkl | | jkl
mno | mno | | mno
pqr | pqr | pqr |
(5 rows)