I have a table Example
like this:
Id, Type, Flags(in integer)
1, A, 8 (B1000)
2, A, 7 (B0111)
3, B, 3 (B0011)
The Flags are stored as integer, but interpreted as Binary. When I group by Type to get the MAX of each Type, I do it like this:
SELECT Type, MAX(Flags)
FROM Example
GROUP BY Type
What can I do to get the Logical OR of all the values in a Group of Flags? eg: what I want is this:
Type, ResultFlags
A, 15 (B1111 = B1000 | B0111)
B, 3 (B0011)
Is there a way to do this in a GROUP BY
clause or any other way which isn't too costly?
I am also curious how you can do this in LINQ to SQL.