sql - Selectively populating result column -


i have query fetches result multiple tables:

select      ta.c1 columna, tb.c1 columnb, tc.c1 columnc       tablea ta, tableb tb, tablec tc      --business conditions 

the result fetched below:

enter image description here

is want result fetched in a separate columnd, has value each corresponding value of columna e.g:

enter image description here

ps: if not null , value of columnb takes priority on value of columnc (for example row 4)

can suggest way achieve ?

you can use coalesce operator.

select ta.c1 columna,         coalesce(tb.c1, tc.c1) columnb        tablea ta, tableb tb, tablec tc 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -