SpinTheMic
Pro

Interview practice question

Finding the longest login streak

Data Analyst · SQL for Analytics · Intermediate

How would you find each user's longest streak of consecutive days with a login?

What a strong answer covers

Your AI report card counts how many of these ideas you cover.

  • Distinct login dates per user.
  • date − ROW_NUMBER() days = group key.
  • Consecutive dates share key (gaps and islands).
  • Count per group.
  • MAX per user.
Practise this topic

Start without signing up. Sign in free to get an AI report card on your answer.

See all topics