Very Simple MySQL Solution
Intuition\n Describe your first thoughts on how to solve this problem. \nThe goal is to calculate the fraction of players who logged in again on the day after t
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe goal is to calculate the fraction of players who logged in again on the day after their first login. \n- This involves identifying players who have consecutive (means one after the other) logins starting from their first login date and then computing the ratio of such players to the total number of players.\n# Code\n```\nselect round(count(distinct player_id)/(select count(distinct player_id) from activity), 2) as fraction\nfrom activity\nwhere (player_id, date_sub(event_date, interval 1 day)) \nin (select player_id, min(event_date) as first_date\nfrom activity\ngroup by player_id)\n```\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- We first identify the players who logged in for at least two consecutive days starting from their first login date. \n- This can be done by **joining the Activity table with itself** and checking if there exists a record for each player where **the event date is the day after their first login date.** using **date_sub()** function\n- We **count the number of distinct players** meeting the above condition.\n- We **divide this count by the total number of distinct players** to obtain the fraction.\n\n(HOPE IT HELPS !!!)\n\n\n
['MySQL']