Typical Yandex/VK task. **Condition:** Calculate Monthly Active Users (MAU) for a music service and the percentage change compared to the previous month. **Table:** listening_history (user_id, played_at, ...) **Requirements:** 1. MAU = number of unique users who listened to at least 1 track in the month 2. Calculate % change: (current_mau - prev_mau) / prev_mau * 100 3. Handle the first month case (prev = NULL) **Hint:** DATE_TRUNC + COUNT(DISTINCT) + LAG.
Sign in to solve
Start Solving