Skip to content
Advertisement

query mysql to find total value

please help me. imagine the table as bellow

and I want to query and show result like this

I dont know how to write query to show result like that. I used (date_join) as dates, count(id) and group by date(date_join) and the result not show like that.

Advertisement

Answer

In MySQL 8.0, you can solve this with aggregation and a window sum:

Or even without aggregation:


In earlier versions, one option is to select the distinct dates and use a correlated subquery to get the running count:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement