MySql SUM() function

后端 未结 2 387
无人共我
无人共我 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条回答
  • 2021-01-27 07:21

    From basic math a + b + c = a + (b + c)

    So just use one sum. It will be equivalent with what you are doing there ..

    0 讨论(0)
  • 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) ...
    
    0 讨论(0)
提交回复
热议问题