同样的语句在?Sqlite中执行比MySql快
-- SELECT temp.name as name,sum(temp.grade_num) as sum from (select u.name,g.grade_num,g.type from user u, grade_info g where u.id=g.user_id and g.type='add') as temp group by name order by sum desc limit 1; -- select t.name,sum(t.grade_num) as sum from (select u.id,u.name,g.grade_num from user u inner JOIN grade_info g on u.id=g.user_id) t group by t.name order by sum desc limit 1; -- select u.name,tem.s from user u inner join (select g.user_id,sum(g.grade_num) as s from grade_info g group by g.user_id order by s desc limit 1) tem on u.id=tem.user_id; select u.name,tem.s from (select g.user_id,sum(g.grade_num) as s from grade_info g group by g.user_id order by s desc limit 1) tem left join user u on u.id=tem.user_id;