Assume a results table like so:
date|user_id
A user can have one or more result per day..
I need to calculate a) users who have entered a result in 30 or more consecutive days b) preferably the longest current streak for a specific user.
The results table is large (2 million results) with approx 50k users.
Alternatively, if this is too difficult, any suggestions of a different way of working this out?
(e.g. create a 'streak' table with user_id, streak number, start date etc and then update that on insert into results, but you'd still need to know if somebody entered a result whether that was part of a streak etc)
Best Answer
To keep track of longest streak and when it occurred.
Table columns needed:
Pseudocode: