Select * from 表 a where price = (select max(price) from 表 where name = a.name)
上面的有点问题 select a.name,a.type,max(a.price) as price from yourtable a group by a.name,a.type
declare @t table(name varchar(10),type int,price numeric(10,2)) insert into @t values('duwei',1,56.3) insert into @t values('kk',2,50) insert into @t values('duwei',1,90) insert into @t values('oo',2,80.7) insert into @t values('kk',2,60) select name,type,max(price) from @t group by name,type
select name,type,max(price) from 表 group by name,type
Select * from 表 a where not exists( select 1 from 表 where a.price<price and name = a.name)
select a.name,a.type,max(a.price) as price from yourtable a
group by a.name,a.type
insert into @t values('duwei',1,56.3)
insert into @t values('kk',2,50)
insert into @t values('duwei',1,90)
insert into @t values('oo',2,80.7)
insert into @t values('kk',2,60)
select name,type,max(price) from @t group by name,type
not exists( select 1 from 表 where a.price<price and name = a.name)