mysql嵌套的时候需要加上别名

select name as id,a+b+c+d s4
from (
SELECT worker_name name,sum(score_posts) a,sum(score_orders) b, sum(score_cutovers) c, sum(score_bonuses) d
from scores_scores
where score_year_month in('2018-11','2018-10','2018-12')
GROUP BY worker_name
)
ORDER BY s4 desc

没有别名提示:
Every derived table must have its own alias

加上别名,正常运行

 
select name as id,a+b+c+d s4
from (
SELECT worker_name name,sum(score_posts) a,sum(score_orders) b, sum(score_cutovers) c, sum(score_bonuses) d
from scores_scores
where score_year_month in('2018-11','2018-10','2018-12')
GROUP BY worker_name
) AS SEASON4
ORDER BY s4 desc


分类: 数据库

0 条评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注