Using SUM() without grouping the results

后端 未结 4 1860
别那么骄傲
别那么骄傲 2020-12-03 10:34

I already read (this), but couldn\'t figure out a way to implement it to my specific problem. I know SUM() is an aggregate function and it doesn\'t make sense n

4条回答
  •  醉话见心
    2020-12-03 10:56

    This does just one sum() query, so it should perform OK:

    SELECT a.id, b.amount
    FROM table1 a
    cross join (SELECT SUM(amount) as amount FROM table1 AS amount) b
    

提交回复
热议问题