Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Longest Consecutive Login Streak per User

HardSQL · PostgreSQL00:00
I
Practice interviewer
Your interviewer
In session
I
Interviewer

Welcome to the SQL screen.

The question is on your right: Longest Consecutive Login Streak per User. Read through the requirements and the one table first.

Run and submit your code as often as you need. You also have five interviewer messages this session - want to talk through your approach, or are you ready to start coding?

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