I hava table with sessions
sessions
-----------------
_id | date
-----------------
1 | 2015-12-25
2 | 2015-12-24
3 | 2015-12-23
4 | 2015-12-22
5 | 2015-12-22
6 | 2015-12-09
7 | 2015-11-04
8 | 2015-05-11
Now how to calculate current consecutive streak, here in the above table
current streak is 22 dec- 25 dec -> 4 days
i can remove duplicate dates using distinct command
SELECT DISTINCT(date) FROM sessions ORDER BY date DESC;
date
-----------------
2015-12-25
2015-12-24
2015-12-23
2015-12-22
2015-12-09
2015-11-04
2015-05-11
Aucun commentaire:
Enregistrer un commentaire