Solution with step-by-step explanation
Approach\n1. Calculate all player\'s first day and then derive next day from it using dateadd function\n2. Apply a join by matching player_id and next_day on th
# Approach\n1. Calculate all player\'s first day and then derive next day from it using dateadd function\n2. Apply a join by matching player_id and next_day on the source table\n3. Resulting count is the number of players, who played on first and second day\n4. Divide by total number of players and the output is obtained \n\n\n# Code\n```\nwith day_log as \n(select player_id, min(event_date) as day1,dateadd(day,1,min(event_date)) as next_day  from Activity a group by player_id)\n\nselect \nround(cast(count(*) as float)/(select count(*) from day_log) ,2) as fraction \nfrom \nday_log a inner join Activity b \non \nb.player_id=a.player_id and  b.event_date =a.next_day \n\n```
['MS SQL Server']