SELECT ID FROM TABLE A
INNER JOIN (SELECT BIANHAO,MAX(SHULIANG) as MSL FROM TABLE GROUP BY BIANHAO) B
ON ISNULL(A.BIANHAO,'')=ISNULL(B.BIANHAO,'') AND A.SHULIANG=B.MSL
Select ID From TableName A Inner Join (Select BianHao,Max(ShuLiang) X From TableName Group By BiaoHao) B On IsNull(A.BianHao,'') = IsNull(B.BianHao,'') And A.ShuLiang = B.X
Select Distinct (Convert(VarChar(10),ID) + Convert(VarChar(10),BianHao)) From TableName A Inner Join (Select BianHao,Max(ShuLiang) X From TableName Group By BiaoHao) B On IsNull(A.BianHao,'') = IsNull(B.BianHao,'') And A.ShuLiang = B.X