SQL: how to count cells accross columns?
Posted on 2012-03-18
dbo.listings has 25 columns
UserID is a primary key
For a userID, I want to select the total count of all cells that are not Null and have a Length of at least > 0. Basically, I want to know for a userID, how many cells contain data (not interested in null or blank cells).
How can I do this?
SO, say userID = 1000.
Lets assume column names are simply Column1, Column2, etc.
How can I craft a statement that gets the count of how many columns have data for UserID 1000