SQL: Calculating Player Engagement Frequency
Code\n\n# Write your MySQL query statement below\nSELECT \n    ROUND( \n        COUNT(*) \n        / (SELECT COUNT(DISTINCT activity.player_id) FROM activity)\n
# Code\n```\n# Write your MySQL query statement below\nSELECT \n    ROUND( \n        COUNT(*) \n        / (SELECT COUNT(DISTINCT activity.player_id) FROM activity)\n    , 2) as fraction\nFROM activity a1\nwhere \n    (a1.player_id, SUBDATE(a1.event_date, INTERVAL 1 DAY)) \n    IN    ( SELECT a2.player_id, min(a2.event_date) AS event_date\n            FROM activity a2\n            GROUP BY a2.player_id )    \n\n```\n![upvote_leetcode.png](https://assets.leetcode.com/users/images/4897652a-2a69-4153-8482-61cc99fb7819_1702916135.434091.png)\n
['MySQL']