I know the method set @running_sum=0;
@running_sum: =@running _sum + ...
, however it doesn't seem to work in my case.
My request:
SELECT DISTINCT(date), COUNT(*) AS count FROM table1 WHERE date > '2011-09-29' AND applicationid = '123' GROUP BY date ORDER BY date
The result gives me unique dates with a count of occurrences of application 123.
I want to save the current amount of count
to see the accumulated growth.
Now I am doing this in PHP, but I want to switch everything to MySQL.
Using the method from the first line of this message simply duplicates the account, and does not accumulate it.
What am I missing?
PS The set is very small, only about 100 entries.
Edit: you're right ypercube:
Here is the version with run_sum:
SET @running_sum=0; SELECT date, @running_sum: =@running _sum + COUNT(*) AS total FROM table1 WHERE date > '2011-09-29' AND applicationid = '123' GROUP BY date ORDER BY date
count count ends the same as if I just typed COUNT (*)
djdy
source share