MySQL: Get the weekly count of every user in table

Viewed 58

I'm a pretty newbie in MySQL and I don't have any idea on how to get the weekly count of every user in my table.

I have a table that looks like this.

user_id when_added
1 September 1, 2021
1 September 4, 2021
1 September 9, 2021
2 September 4, 2021

What this does is I insert a row every time a particular user views a video.

I'm trying to get a result that looks like this.

user_id week count
1 Sept 1 - Sept 7 2
1 Sept 8 - Sept 14 1
2 Sept 1 - Sept 7 1

Is it possible in Mysql? Thanks

0 Answers
Related