Ash Machine Ash Machine - 7 months ago 66
SQL Question

SQL : How to sum multiple bit columns in a row

I have a data structure that has repeating bit columns per row

enter image description here

How to I get the total number of Trues for each row? For example

Id Total

03 2

17 0

21 3

24 2


Cast the bit to Int and do the arithmetic operation

select id,cast([Ok_1112] as Int)+cast([Ok_1213] as Int)+...
From yourtable