sql - Select another attribute if the original attribute is NULL (Conditional select) -


how can achieve if want select attribute , if attribute null.

i know long way of this:

select val1 test_table val1 not null or select val2 test_table val1 null 

the bad solution if have long , complicated select need write twice...

eg:

select val1 test_table condition1 , condition2 , condition3 , val1 not null or select val2 test_table condition1 , condition2 , condition3 , val1 null 

so hope, maybe there shorter form this. anyway if or case in programming languages (i think).

any idea appreciated. first ide: inside select can shorten second select

select coalesce(val1, val2) test_table 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -