I was playing around with Cohort Analysis in Google Analytics and was trying to figure out how to write it in SQL. There is a pretty extensive answer to this from about 5 years ago for MySQL here: Cohort analysis in SQL. However, I was wondering if with the new window
functions in mysql8, this might have gotten significantly more easy. For example, to reproduce this:
I would assume the data is something like:
- timestamp
- user_id
- user_creation_timestamp
And it seems like the date interval is per week over the past 6 weeks. Does the window/partitioning functions make this any easier now?