3

在 MySQL 中是否有一种优雅的方法可以做到这一点:

SELECT (subquery1) AS s1, (subquery2) AS s2, (s1+s2) AS s3

或者我必须求助于

SELECT (subquery1) AS s1, (subquery2) AS s2, ((subquery1)+(subquery2)) AS s3

?

谢谢

编辑:两个子查询都产生整数结果

4

1 回答 1

3

您可以在 MySQL 中使用变量


SELECT @query1:=(subquery) AS s1, @query2:=(subquery) AS s2, (@query1+@query2) AS s3

仍然没有那么优雅。也许您可以详细说明子查询,以便我们可以提出更好的方法?

于 2009-07-10T06:02:03.300 回答