Count Boolean by Row (1 Viewer)

databasedonr

Registered User.
Local time
Today, 03:04
Joined
Feb 13, 2003
Messages
163
Hi,

I have a table with seven boolean fields: I need to count all the "trues" and return the row if the sum of the trues is greater than 3.... and I am not sure how to do this. Any thoughts?

Thanks!
 

CJ_London

Super Moderator
Staff member
Local time
Today, 08:04
Joined
Feb 19, 2013
Messages
16,739
WHERE -(B1+B2+B3+B4+B5+b6+B7)>3

with Booleans, true=-1 and false=0 and you can add them as above
 

databasedonr

Registered User.
Local time
Today, 03:04
Joined
Feb 13, 2003
Messages
163
Thanks CJ_London, that worked a treat. I was making it far more complex, trying to sum the fields and group by etc, and was getting nowhere. This does exactly what I want very neatly. Thanks again.
 

Users who are viewing this thread

Top Bottom