I need to make a column that counts the amount of variables which are above 0, and that won't return null if there is any non-null value in it, for each value in an id column.
What I managed to make is using a sum between some boolean operations:
IF 'A' THEN 'B' ELSE 'C' (at least that's what I've got)
select ID, `jul`, `aug`, `set`, `oct`, `nov`, `dec`,
((((not `jul`) or 1) and (`jul` or 0))
+(((not `aug`) or 1) and (`aug` or 0))
+(((not `set`) or 1) and (`set` or 0))
+(((not `out`) or 1) and (`out` or 0))
+(((not `nov`) or 1) and (`nov` or 0))
+(((not `dec`) or 1) and (`dec` or 0))) as sum from table;
It works at first view, but if there is any null value in a line, the sum returns null for each respective id.
What could I do to avoid this problem?