Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Query Player Churn

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

Your question is Query Player Churn. Start with the requirements and the two tables 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

Ubisoft wants to monitor player engagement across titles such as Rainbow Six Siege. Using an analysis date of 2025-02-01, write a PostgreSQL query that classifies each player according to their most recent session.

Requirements

  1. Use the latest session for each player and calculate inactivity days relative to 2025-02-01.
  2. Classify players as active for fewer than 14 inactive days, at_risk for 14 to 29 days, churned for 30 or more days, and never_played when no session exists.
  3. Return every player, including players without matching sessions, and order results by status priority, inactivity days descending, and player ID.

Schema

players
ColumnTypeDescription
player_idPKINTUnique player identifier
usernameVARCHAR(100)Ubisoft player name
regionVARCHAR(30)Player geographic region
game_sessions
ColumnTypeDescription
session_idPKINTUnique session identifier
player_idINTPlayer associated with the session
game_titleVARCHAR(100)Ubisoft game title
session_started_atTIMESTAMPSession start timestamp
platformVARCHAR(30)Gaming platform
Tablesplayersgame_sessions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results