sql server - Case Statement if all NULL or at least one value present -


i doing wrong, here's detail on i'm @ thinking.

i have table, we'll call table:

test     id     value test_1   01     50 test_2   01     null test_3   01     40/50 test_1   02     null test_2   02     null 

summary

i looking make case expression can if test values null 'no' if @ least 1 test value has value 'yes'.

desired output:

id   case 01   yes 02   no 

current query:

select     id    ,case when t.test in ('test_1','test_2','test_3') not null         'yes'         else 'no'  end table t 

error

incorrect syntax near keyword 'is'.

using aggregate....

declare @table table (test varchar(6), id int, value varchar(24)) insert @table values ('test_1','01','50'), ('test_2','01',null), ('test_3','01','40/50'), ('test_1','02',null), ('test_2','02',null)  select     t.id     ,case when min(t.value) null , max(t.value) null 'no' else 'yes' end [case]     @table t group     t.id 

and really, need check once.

select     t.id     ,case when max(t.value) null 'no' else 'yes' end [case]     @table t group     t.id 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -