在MySQL中是否有一种优雅的方法可以做到这一点:
SELECT (subquery1) AS s1, (subquery2) AS s2, (s1+s2) AS s3
还是我必须诉诸
SELECT (subquery1) AS s1, (subquery2) AS s2, ((subquery1)+(subquery2)) AS s3
?
谢谢
编辑:两个子查询产生整数结果
解决方法:
您可以在MySQL中使用变量
SELECT @query1:=(subquery) AS s1, @query2:=(subquery) AS s2, (@query1+@query2) AS s3
仍然没有那么优雅.也许您可以详细说明子查询,以便我们可以提出更好的方法?