22,209
社区成员
发帖
与我相关
我的任务
分享
select myid,price = max(price) from @tb group by myid
-->测试数据
declare @tb table (Myid int,price int)
insert into @tb
select 1,8 union all
select 2,4 union all
select 2,6 union all
select 3,3 union all
select 3,5 union all
select 3,7 union all
select 4,10 union all
select 4,11 union all
select 4,50 union all
select 4,90
select myid,max(price) from @tb group by myid
--结果
myid
----------- -----------
1 8
2 6
3 7
4 90
select myid,max(price) from mytable
group by myid
select myid,max(price) as price from tb group by myid
select myId,max(price) from mytable
group by myId
order by myId