u_1*_*148 0 sql sql-server stored-procedures sql-server-2008 sql-server-2012
我有一个select语句,它返回每个标记的元素数组:
|TAG  | Bool1 | Bool2 | Bool3 |
|-----------------------------|
|tag1 |  0    |   1   |  0    |
|tag1 |  1    |   1   |  0    |
-------------------------------
我希望结果是两行与OR语句的并集:
_______________________________
|TAG  | Bool1 | Bool2 | Bool3 |
|-----------------------------|
|tag1 |  1    |   1   |  0    |
-------------------------------
SELECT TAG,
    CAST(MAX(CAST(Bool1 as int)) as bit) as Bool1,
    CAST(MAX(CAST(Bool2 as int)) as bit) as Bool2,
    CAST(MAX(CAST(Bool3 as int)) as bit) as Bool3
from Table group by TAG
似乎适合该法案,因为即使单行有一个1值,也会克服0其他行中的所有s.