高人!关于distinct祛除重复和order by的使用 我的sql语句如下: select distinct detailsId,commodityColor from Details where commodityId='100081' order by commodityColor asc主要是想查出来"commodityColor"并且祛除它的重复项 再按照detailsId排序
------解决方案-------------------- order by distinct commodityColor asc 试试
------解决方案--------------------
SQL code
select detailsId = MIN(detailsId),commodityColor --或用max(detailsId)
from Details
where commodityId='100081'
GROUP BY commodityColor
ORDER BY detailsId
------解决方案--------------------
------解决方案-------------------- select detailsId = MIN(detailsId),commodityColor --或用max(detailsId) from Details where commodityId='100081' GROUP BY commodityColor ORDER BY detailsId