Rumah > Soal Jawab > teks badan
表结构和数据如下,我需要查询uid的total之和最大的前10条数据,请问sql语句如何写
uid total
1 4
2 1
2 2
3 6
1 5
4 9
巴扎黑2017-04-10 14:39:24
SELECT uid, SUM( total )
FROM `test`
GROUP BY uid
ORDER BY SUM( total ) DESC
LIMIT 0 , 10