求和排序的问题
SELECT A.*, B.total_cost, B.total_son_cost
FROM sso_user AS A, sso_user_fee AS B
WHERE A.userid = B.userid
AND A.user_type = 2
ORDER BY sum(B.total_cost + B.total_son_cost) DESC
这条语句不能按sum的和去排序,而且只能查询一条记录出来!
多谢请帮忙一下,比较急!
------解决方案--------------------SELECT A.*, sum(B.total_cost+ B.total_son_cost) as sum_total
FROM sso_user AS A, sso_user_fee AS B
WHERE A.userid = B.userid
AND A.user_type = 2
ORDER BY sum_total DESC
试一下.