-5

我的问题是:

select
    ProdID, Qualified 
from 
    VarAnn_Data.dbo.tblOwnership

程序输出:

ProdID(num) Qual (Bit)
26  0
26  0
26  1
26  0
26  1
26  0
26  0
27  0
28  0
28  0
28  0
28  0
28  0
28  1
28  1
29  0
29  0
29  1
29  0
29  1
29  0
29  0

现在 single 有多个 1 和 0 prodid。我得到了不同的结果

情况1:

ProdId(num)      Quak(bit)
26                  0
26                  1

结果:一个

ProdId(num)      Quak(bit)
26                  0

结果:B

ProdId(num)      Quak(bit)
26                  1

结果:C

4

1 回答 1

2

这是你想要的?

select ProdID, 
       min(Qualified),
       case when min(Qualified) <> max(Qualified) 
            then 'YES'
            else 'NO'
       end as Has_different_results
from VarAnn_Data.dbo.tblOwnership
group by ProdID
于 2012-11-11T10:09:41.367 回答