help with t-sql data aggregation

Posted by stackoverflowuser on Stack Overflow See other posts from Stack Overflow or by stackoverflowuser
Published on 2010-05-28T23:15:58Z Indexed on 2010/05/28 23:22 UTC
Read the original article Hit count: 192

Filed under:
|
|
|

Based on the following table

Area  S1 S2 S3 S4 
--------------------
A1    5  10 20 0
A2    11 19 15 20
A3    0  0  0  20

I want to generate an output that will give the number of columns not having "0".

So the output would be

Area  S1 S2 S3 S4   Count 
-------------------------
A1    5  10 20 0    3
A2    11 19 15 20   4
A3    0  0  0  20   1

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server