sql server 2008 - SELECT statement needs to output value conditional on NULL data -


It was hard to summarize the title I needed ... it goes here. This is for SQL Server 2008.

For a reason which is too long to explain here, I want a SELECT statement displayed between the other columns, if 1 is the value of 1 if there is a value in the 4 column zero something like that.

  Select name, last name, P1, P2, P3, P4, "1 if P1, P2, P3 and P4 are all zero, otherwise" The question is how do I translate this code:  "1 if p1, p2, p3 and p4 are all zeroes, 0 otherwise the city, st, and zip mytable   

"?

I tried

  case lane (P1 + P2 + P3 + P4) when zero 1 ELSE 0 END   < P> But it was not working. Even if I << p> 
  select len ​​(p1 + p2 + p3 + p4) from mytable   

results iS NULL

If I tried, but you are not welcome in a selection statement.

Thoughts?

Thank you.


Thanks guys. I chose the answer which does not use coal because I understand it. I tried to read MS's interpretation here: And I still did not understand completely, and this note is saying that "There should be a tap typed in at least one zero values" I was a little scared Thank you for all.


Try this:

  SELECT      html>

Comments