Is it possible to sum all row which has been summed?
For instance I have this query:
SELECT SUM(registered) AS `totalOftheDay`
FROM table
WHERE DATE(ds.register_time) BETWEEN '2015-03-01 00:00:00' AND '2015-03-30 23:59:59'
GROUP BY DATE(ds.register_time)
What I need is when total of registered people has been summed by date (group by
) then I want to sum it again base on the month. So I got two results: based on date and based on month. How to do that if it is possible to do that in sql query?
Thanks for the help. Cheers!
For example:
+-----------------------+----------------+
register_time registered
+-----------------------+----------------+
2015-03-01 01.00.00 20
2015-03-01 02.00.13 40
2015-03-01 03.01.10 60
2015-03-01 04.20.00 80
2015-03-01 05.01.10 20
2015-03-01 13.00.00 20
----------------------------------------TOTALOFTHEDAY SUM 240
2015-03-02 13.00.00 20
2015-03-02 14.00.00 20
2015-03-02 15.00.00 20
----------------------------------------TOTALOFTHEDAY SUM 60
2015-03-03 13.00.01 20
2015-03-03 14.00.02 20
2015-03-03 15.00.03 20
2015-03-03 16.00.04 20
2015-03-03 17.00.05 20
----------------------------------------TOTALOFTHEDAY SUM 100
After I summed the total registered user by date, then I want to sum it again:
240 + 60 + 100 = 400 (TOTALOFTHEMOTHN)