My goal is to get cumulate number of users registered by date
Here is my mysql sql
SELECT MONTH( DATE ) AS `month`, COUNT(userid)
FROM `stats`
WHERE `userid` = 1
GROUP BY `month`
This gives me number of users per month, but does not cumulate them
result:
month 1 : 90
month 2 : 50 (it should be 90 + 50)
month 3 : 10 (it should be 90 + 50 + 10)
I tried:
SELECT month,
SUM( CNT ) AS CUM_CNT_TILL_NOW
FROM (
SELECT MONTH( DATE ) AS `month`, COUNT(userid) AS CNT
FROM `stats`
WHERE `userid` = 1
GROUP BY `month`
);
and got error: #1248 - Every derived table must have its own alias