这是我想要得结果:
----------------------------------------------------
ID CompanyID ProductDetailID Count
10 50 682 A
14 60 689 C
18 70 697 E
-----------------------------------------------------
----------------------------------------------------
ID CompanyID ProductDetailID Count
10 50 682 A
14 60 689 C
18 70 697 E
-----------------------------------------------------
from 表 a,(select min(ID) as id,CompanyID,ProductDetailID
from 表
group by CompanyID,ProductDetailID ) b
where a.id=b.id
(select id=min(id),CompanyID,ProductDetailID from t group by ompanyID,ProductDetailID) a
where t.id=a.id and t.CompanyID=a.CompanyID and t.ProductDetailID=a.ProductDetailID
a.*
from
tabname a
inner join
(select CompanyID,ProductDetailID ,min(ID) as ID
from tabname
group by CompanyID,ProductDetailID ) b
on
a.CompanyID = b.CompanyID and a.ProductDetailID = b.ProductDetailID and a.ID = b.ID
where not exists (select * from 表 where companyid=a.companyid and productdetailid=a.productdetailid and id<a.id)
from
(select min(ID) as id,CompanyID,ProductDetailID
from Table
group by CompanyID,ProductDetailID ) a
left join Table b on a.ID=b.ID
select * from 表名 as a where not exists (select * from 表名 where CompanyID=a.CompanyID and ProductDetailID=a.ProductDetailID and [ID]<a.[ID])