assuming that I have a db that have an horizontal structure like this:
ID | NAME | DATA1 | DATA2 | DATA3 | DATA4 | DATA5 | DATA6 | DATA7
1 | mmm | 0 | 1 | 0 | 3 | 5 | 1 | 0
2 | bbb | 0 | 0 | 0 | 1 | 0 | 1 | 1
the informations are the data fields and I would like to count all the times that a certain discriminant, such as "is more than 0"
the way I thought it is loop trought all the fields, and count, or COUNT()
each DATA
field, so SUM()
those 7
queries... anyone has another idea?
in this case the result, so "count every DATA field with a value over 0"
would be = 7