simple CTE solution beats 75%
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Creat
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Create column is_return as returned on 2nd date indicator\n\n\n- date_sub() function work well for all date, eg. previous day is 02-29, 2nd date is 03-01\n- CTE show the origintal table plus the is_return column\n- sum()/count() simple calculate the result. \n\n\n# Code\n```\n\n#1 count of player logged in on the second day--- should return a single number <=3 current view\n#2 count of all distinct player. ----should return 3 based on the current view\n# 1/2 as fraction\n\n\n\n\nwith cte as (\n  select player_id, DATE_SUB(event_date, INTERVAL 1 DAY)=min(event_date) over(partition by player_id) as is_return from activity\n  )\nselect round(sum(is_return)/count(distinct player_id), 2)  as fraction from cte
['MySQL']