过滤重复数据
字段1 ListClothID 字段2 ListClothImageSmall
1 222
1 333
1 444
2 555
2 ddd
3 f
3 v
想得到 1 222
2 555
3 f
select a.ListClothID , b.ListClothImageSmall
from (select distinct ListClothID from ListClothImage) as a left join ListClothImage b on a.ListClothID = b.ListClothID
[解决办法]
SELECT ListClothID, ListClothImageSmallFROM (SELECT Row_number() OVER( ORDER BY a.ListClothID )rn, a.ListClothID, b.ListClothImageSmall FROM (SELECT DISTINCT ListClothID FROM ListClothImage) AS a LEFT JOIN ListClothImage b ON a.ListClothID = b.ListClothID)bWHERE rn = 1
[解决办法]
SELECT ListClothID, ListClothImageSmallFROM (SELECT Row_number() OVER( ORDER BY a.ListClothID )rn, a.ListClothID, b.ListClothImageSmall FROM (SELECT DISTINCT ListClothID FROM ListClothImage) AS a LEFT JOIN ListClothImage b ON a.ListClothID = b.ListClothID)bWHERE rn = 1