怎么得到某字段最大的记录.在线等待,当场结分.
klggg 2002-10-12 05:18:03 表PactRate
id PactId GatheringYear PactCost
1 1 1999 12000
2 1 2000 12000
3 3 1002 12000
4 4 2002 50000
5 5 2002 100
运行 mysql语句
select * from PactRate group by PactId
得到
id PactId GatheringYear PactCost
1 1 1999 12000 *
3 3 1002 12000
4 4 2002 50000
5 5 2002 100
但我想要得到这样的结果
id PactId GatheringYear PactCost
2 1 2000 12000 *
3 3 1002 12000
4 4 2002 50000
5 5 2002 100
也就是说 得 存在PactId重复的记录时取GatheringYear 最大的那个.
应该怎么做!
在线等待.