MySql SUM() function

后端 未结 2 388
无人共我
无人共我 2021-01-27 06:43

Is it possible to use MySql SUM() function inside another MySql SUM() function ??

Like below

$query=\"SELECT SUM(Table1.Column1+SUM(Table2.Column2+Table2         


        
2条回答
  •  梦毁少年i
    2021-01-27 07:23

    You just need one SUM():

    SELECT SUM(Table1.Column1 + Table2.Column2 + Table2.Column3) ...
    

    Or use SUM() on each field:

    SELECT SUM(Table1.Column1) + SUM(Table2.Column2) + SUM(Table2.Column3) ...
    

提交回复
热议问题