All tasks

User Retention (Retention Analysis)

Expert

Task at FAANG/Meta level. **Condition:** Find users who were active (listened to music) every month for 3 consecutive months. **Table:** listening_history (user_id, track_id, played_at, ...) **Requirements:** 1. Group activity by months 2. Find sequences of 3 consecutive months for each user 3. Output user_id and activity period (start_month, end_month) **Hint:** Use the Gaps & Islands pattern with LAG/LEAD or ROW_NUMBER.

Category
Window Functions
Estimated time
~30 min
Databases
PostgreSQLGreenplum
Tags
FAANGInterviewRetentionLAGGaps & Islandsоконные функции

Sign in to solve

Start Solving