Easy and Simple Solution
Please Like ❤️IntuitionThe problem asks us to compute the fraction of players who logged in on the first day after their initial login day.Approach
Subquery for
```mysql
# Write your MySQL query statement below
SELECT ROUND(COUNT(DISTINCT player_id) / (SELECT COUNT(DISTINCT player_id) FROM Activity), 2) as fraction
FROM Activity
WHERE (player_id, DATE_SUB(event_date, INTERVAL 1 DAY))
IN (SELECT player_id, MIN(event_date) AS first_login FROM ACTIVITY GROUP BY player_id)
```

# Please Like ❤️  
![Please Like](https://media.tenor.com/heEyHbV8iaUAAAAM/puss-in-boots-shrek.gif)

# Intuition  
The problem asks us to compute the fraction of players who logged in on the first day after their initial login day.

# Approach  
1. **Subquery for First Login:**  
   The inner query selects the earliest `event_date` for each `player_id` using `MIN(event_date)`. This represents each player's first login day.
2. **Main Query:**  
   - The `WHERE` clause checks for players whose login date is exactly one day after their first login day.
   - The `COUNT(DISTINCT player_id)` counts the number of such players.
   - We then divide this count by the total number of distinct players (using the subquery) to get the fraction.
   - The result is rounded to two decimal places.

# Complexity  
- **Time Complexity:**  
  $$O(n)$$ where `n` is the number of rows in the `Activity` table. We perform a scan of the data twice: once for the subquery and once for the main query.
  
- **Space Complexity:**  
  $$O(n)$$ as we store intermediate results (distinct player IDs) in both the subquery and the main query.
['MySQL']