case when | cte I easy-to-understand solution MS SQL
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- Time 
# 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- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/* Write your T-SQL query statement below */\nwith v1 as(\nselect\nplayer_id,\nmin(event_date) first_login\nfrom activity\ngroup by player_id\n)\nselect \nround(cast(sum(case when datediff(day, first_login, event_date) = 1 then 1 else 0 end) as float)/count(distinct v1.player_id), 2) as fraction\nfrom v1\njoin activity a on a.player_id = v1.player_id\n\n```
['MySQL', 'Oracle', 'MS SQL Server']