Calculate a running total in MySQL

后端 未结 8 2306
别那么骄傲
别那么骄傲 2020-11-22 00:37

I have this MySQL query:

SELECT DAYOFYEAR(`date`)  AS d, COUNT(*) 
FROM  `orders` 
WHERE  `hasPaid` > 0
GROUP  BY d
ORDER  BY d

Which re

8条回答
  •  别跟我提以往
    2020-11-22 00:43

    This is one of the only places where cursors are faster than a set based queries, if performance is critical I would either

    • Do this outside of MySql or
    • Use MySql 5 Cursors

提交回复
热议问题