This is my query:
SELECT [id],[reasoncode],
[jan], [feb],[mar],[apr],[may,[jun],
[jul],[aug],[sep],[oct],[nov],[dec] from table
Now what I want to know is if there is another way to filter away 0 using WHERE than this??
SELECT [id],[reasoncode],
[jan], [feb],[mar],[apr],[may,[jun],
[jul],[aug],[sep],[oct],[nov],[dec] from table
WHERE
[jan] <> 0 and
[feb] <> 0 and
[mar] <> 0 and
[apr] <> 0 and
[may] <> 0 and
[jun] <> 0 and
[jul] <> 0 and
[aug] <> 0 and
[sep] <> 0 and
[oct] <> 0 and
[nov] <> 0 and
[dec] <> 0
from table
Suggestions?
——Update
I only want to exclude the row if all the rows have zero.
This is the data I have to work with, so there is not a “month” column available.
Since you want to exclude where all the (month) columns are 0 then add all of the month columns together and test like so
This assumes that your valid values for each of the month columns are 0 or positive, and that the columns are int columns not bit columns. If negative values are allowed for each month, then you could use
and if you are using bit columns then