SQL中DISTINCT 后面有多个字段, 如何操作

来源:互联网 发布:淘宝司法拍卖车攻略 编辑:程序博客网 时间:2024/06/05 15:49
select distinct b.oldid,max(b.unit)   --max(b.unit)是重点
 from [MBOM] a join MaterialData b on a.[Component] = b.[NewId] 
 where a.[Processing] ='830'
 group by b.oldid,b.unit
order by b.OldId