LeetCode solutions

1182. Game Play Analysis IV

My accepted SQL solution to LeetCode problem 1182, Game Play Analysis IV, running in 528ms.

  • Difficulty: Medium
  • SQL
  • Runtime 528ms
  • Memory 0.0B

Read the problem on LeetCode View on GitHub

SQL

Accepted on LeetCode — runtime 528ms, memory 0.0B, accepted 2025-12-29.

sql
SELECT ROUND(COUNT(DISTINCT a.player_id) / (SELECT COUNT(DISTINCT player_id) FROM Activity), 2) AS fraction
FROM Activity a
JOIN (
    SELECT player_id, MIN(event_date) AS first_login
        FROM Activity
            GROUP BY player_id
            ) f ON a.player_id = f.player_id AND a.event_date = DATE_ADD(f.first_login, INTERVAL 1 DAY)

Source