Need to select value after verifying multiple columns

hi all,

I have a table with column aa,bb,cc,dd i need to select the a value from these columns after checking the conditions below,

1.if dd is not null then dd
2.if dd is null and cc is not null then cc
3.if dd and cc is null and bb is not null then bb.

i'm not sure how to write a Query for this since. Help me to get this resolved.

select case when dd is not null then dd
when dd is null and cc is not null then cc
when dd is null and cc is null and bb is not null then bb end as NewColumn
from columnss

1 Like

SELECT COALESCE(dd, cc, bb)

1 Like