Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Longest Consecutive Login Streak per User

HardSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Longest Consecutive Login Streak per User. Start with the requirements and the one table on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

A social media platform tracks user logins and wants to analyze user engagement. Write a SQL query to find the longest consecutive streak of login days for each user.

Requirements

  1. Identify consecutive login days for each user.
  2. Calculate the length of each streak.
  3. Return each user with their longest streak.

Schema

user_logins
ColumnTypeDescription
user_idINTUnique identifier for the user
login_dateDATEDate of user login
Tablesuser_logins
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results