日期:2014-05-17 浏览次数:20778 次
select DISTINCT Name,CharacteristicCode from Characteristic where ProductGroupCode='PLBDT' and (Status = -1 or Status=1)
------解决方案--------------------
name有重复那么CharacteristicCode有没有重复呢?
如果只是name有重复,CharacteristicCode没有,那你想去掉重复的name,CharacteristicCode就要有个选取标准,是取最大值还是最小值,加个max就可以了。
如果都重复的话,那么直接distinct就可以了。
------解决方案--------------------
select Name,CharacteristicCode from Characteristic AS A where ProductGroupCode='PLBDT' and (Status = -1 or Status=1) and CharacteristicCode = (SELECT TOP 1 CharacteristicCode FROM Characteristic WHERE A.Name = Name)