日期:2014-05-18  浏览次数:20539 次

2个字段比较~
OutStockDetailID         GoodsID
1                                       200703010001
1                                       200703010001
1                                       200703010001
2                                       200703010005
2                                       200703010005
3                                       200703010007
3                                       200703010008


这一个表里的2个字段   如果OutStockDetailID和GoodsID的内容一摸一样就不显示,如果不一样(OutStockDetailID为3的对着GoodsID有2种)就显示出来     要怎么写?




------解决方案--------------------
select OutStockDetailID,GoodsID from t1 group by OutStockDetailID GoodsID having count(1)> 1;
------解决方案--------------------
Select Table_1.OutStockDetailID,Table_1.GoodsID
From Table_1 join (Select OutStockDetailID,Stdev(cast(GoodsID as int)) Count
From Table_1 Group By OutStockDetailID) temp on Table_1.OutStockDetailID=temp.OutStockDetailID and temp.Count> 0