All tasks

Detecting Periods of Inactivity

Intermediate

Product Analytics level task. **Condition:** Find users who had periods of inactivity longer than 30 days in their listening history. **Table:** listening_history (user_id, track_id, played_at, ...) **Requirements:** 1. For each user, find gaps > 30 days between listens 2. Output user_id, gap_start, gap_end, gap_days 3. Sort by gap length DESC **Hint:** LAG for previous date + calculate difference.

Category
Window Functions
Estimated time
~20 min
Databases
PostgreSQLGreenplum
Tags
InterviewGap DetectionTime SeriesLAGоконные функции

Sign in to solve

Start Solving