PrepZone Logo
PrepZone
Back to Database

Database · Hard

Find the longest streak of consecutive daily logins per user.

DatabaseSQL QueriesStaffWindow Functions

Answer preview

Classic gaps-and-islands: subtract a row number from the date to get a constant group key per streak, then aggregate on that key.…