Sum Bit Fields? (1 Viewer)

databasedonr

Registered User.
Local time
Today, 00:49
Joined
Feb 13, 2003
Messages
163
I have a table with seven bit fields, and I want to select the records where the total of all the bit fields is greater than 3. Is this possible?

Thanks.
 

jdraw

Super Moderator
Staff member
Local time
Today, 00:49
Joined
Jan 23, 2006
Messages
15,396
How about showing readers a bit of your code to help with your set up?
 

jdraw

Super Moderator
Staff member
Local time
Today, 00:49
Joined
Jan 23, 2006
Messages
15,396
Good catch plog.
 

databasedonr

Registered User.
Local time
Today, 00:49
Joined
Feb 13, 2003
Messages
163
Access vs SQL Server. This works great in Access but does not translate to SQL Server.
 

plog

Banishment Pending
Local time
Yesterday, 23:49
Joined
May 11, 2011
Messages
11,670
My test shows that you can add Yes/No fields just like described in that post. What exactly is happening in Access? Error, incorrect results, etc?
 

databasedonr

Registered User.
Local time
Today, 00:49
Joined
Feb 13, 2003
Messages
163
It's was working fine in Access, which was one case I had - I tried the same solution in SQL Server, which did not work. I was able to solve it by flipping the values in SQL and adding them, like this:

(CASE WHEN bool1 = -1 then 1 else 0 end) + (Case WHEN bool2 = -1 then 1 else 0 end) ... and so on.

Thanks for looking, I have it working.

I can post the final SQL Server query if anyone wants to see it.
 

Users who are viewing this thread

Top Bottom