我有一张桌子:
ID | User | Amount
1 | 1 | 50
2 | 1 | 80
3 | 2 | 80
4 | 2 | 100
5 | 1 | 90
6 | 1 | 120
7 | 2 | 120
8 | 1 | 150
9 | 2 | 300
我做一个查询:
SELECT * FROM TABLE ORDER BY amount DESC group by userid
我得到这个:
ID | User | Amount
1 | 1 | 50
2 | 1 | 80
但我期待:
ID | User | Amount
9 | 2 | 300
8 | 1 | 150
我的sql有什么问题?