I am trying to run a query that gets the cumulative sum of a column in one of my tables. It looks like this:
set @csum := 0;
select order_date, Amount, (@csum := @csum + Amount) as cumulative_sum
from Orders
order by order_date
However, when running this, I get all NULLs for the cumulative_sum. Anything I"m doing wrong? Thanks!
@csum, it's probably going to be initialised as an INT, and 'Amount' is probably - what, decimal? Tryset @csum := 0.0;