日期:2014-05-16 浏览次数:20745 次
mysql> select * from users; +----+------+---------+ | id | name | moneyto | +----+------+---------+ | 1 | a | 500.500 | | 2 | b | 200.000 | | 3 | c | 500.000 | | 4 | d | 200.000 | | 5 | a | 600.500 | | 6 | b | 500.000 | | 7 | c | 300.500 | | 8 | d | 100.000 | +----+------+---------+ 8 rows in set (0.00 sec) mysql> select * from (select name,sum(moneyto)as moneyto from users group by name) as a order by moneyto desc limit 0,1; +------+----------+ | name | moneyto | +------+----------+ | a | 1101.000 | +------+----------+ 1 row in set (0.00 sec)