I have the following table called MyTable
First Second Third Fourth
1 Ab Cd 2.3
1 Cq Fe 3.4
2 Dr Dh 1.2
3 Bb Qd 9.8
..........ETC.....................
How can I select the rows grouped by First that have a maximum Fourth column value. So it would be a query that results in
First Second Third Fourth
1 Cq Fe 3.4
2 Dr Dh 1.2
3 Bb Qd 9.8
解决方案
Try this solution:
select MT.First, MT.Second, MT.Third, MT.Fourth
from MyTable MT
join ( select first, max(Fourth) as Fourth
from MyTable
group by first
) T on T.first = MT.First
and T.Fourth = MT.Fourth