Bitwise operation in Group By
问题 I must use bitwise operations in a group by query but I didn't found anything. Table: PermissionId, BitMask(BigInt) 1, 4 2, 7 1, 8 1, 5 I want results as: 1, 13 2, 7 How can I write this script in T-SQL as below SELECT PermissionId, BIT_OR(BitMask) FROM table GROUP BY PermissionId 回答1: Your question just became very interesting. Create this function(you may want to reconsider the name) CREATE function f_test ( @param bigint ) returns @t table (value bigint) AS BEGIN ;WITH CTE AS ( SELECT