Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Longest Consecutive Login Streak per User
00:00
5 left

Longest Consecutive Login Streak per User

HardSQL · PostgreSQL

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
Interviewer

Your question is Longest Consecutive Login Streak per User. Start with the requirements and the one table in the Question tab.

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.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.