MYSQL如何将两个连接字段相加

时间:2015-07-29 02:29:00

标签: mysql sum

嗨您是否知道如何将两个已定义的字段相加?这是可能的吗?

SELECT SUM(a) as total_a, SUM(b) as total_b, (total_a + total_b) as grand_total
FROM table

如果没有,我怎么能想出这个?

2 个答案:

答案 0 :(得分:2)

您也可以在内嵌中执行此操作:

find . -iregex '.*afilename[01][0-9][0-3][0-9]'

答案 1 :(得分:1)

您需要创建一个子查询。

SELECT sum_ab.total_a + sum_ab.total_b as grand_total
FROM 
  (SELECT SUM(a) as total_a, SUM(b) as total_b
   FROM table
  ) as sum_ab