How can I use SUM for bit columns?

前端 未结 7 1113
栀梦
栀梦 2021-01-01 10:45

How can use the function SUM() for bit columns in T-SQL?

When I try do it as below:

SELECT SUM(bitColumn) FROM MyTable;

I get the e

7条回答
  •  遥遥无期
    2021-01-01 11:02

    You can achieve by using CONVERT,

    SELECT SUM(CONVERT(INT, bitColumn)) FROM MyTable
    

提交回复
热议问题