标签: mysql sql
如何正确运行此查询:
SELECT sum(1+1) as sum1, sum(sum1 + 2) as sum2
我想创建变量sum1并在其他函数中使用它!
答案 0 :(得分:3)
使用子查询来表示别名:
select sum1 , sum(sum1 + 2) as sum2 from ( select sum(1+1) as sum1 ) as SubQueryAlias