Interview Questions/SQL/Game Play Analysis IV

Game Play Analysis IV

Preview mode. Log in to edit, run, submit, and save progress.

Medium

Game Play Analysis IV

You have an Activity table that logs when players played games. Each player has a first login date (the minimum event_date for that player). Write a SQL query to report the fraction of players who logged in again the day immediately after their first login date. Round the result to 2 decimal places. (player_id, event_date) is the primary key.

Examples

Example 1

Player 1 logged in on 2016-03-01 (first login) and again on 2016-03-02 (next day). Players 2 and 3 did not log in the day after their first login. So 1 out of 3 = 0.33.

Approach hint

Start with a simple approach, explain the trade-off, then move toward a cleaner or more scalable solution.

Common mistake

Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.

query.sql