How to SUM Bit Fields in SQL

By default, SQL Server doesn’t allow an operation like this:

In order to achieve this result, you must first convert the bit column to a numeric type:

This counts the number of times the bit is true.

If you want to get the flip-side of that to see how many times the bit is false, just subtract the total number of bits from the positive:

Tags:

Leave a Reply