100 % || INTUITIVE && Well - Defined || SQL QUERY || AGGREGATION || Beats 97.91 % || ( Explained )..
Intuition\n Describe your first thoughts on how to solve this problem. \nSELECT ROUND(COUNT(DISTINCT player_id) / (SELECT COUNT(DISTINCT player_id) FROM Activit
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSELECT ROUND(COUNT(DISTINCT player_id) / (SELECT COUNT(DISTINCT player_id) FROM Activity), 2) --> Calculate fraction Using Aggregation function after that we have to round off upto 2 decimal places...\nAS fraction --> alias as fraction...\nFROM Activity --> Association from Activity table...\nWHERE (player_id, DATE_SUB(event_date, INTERVAL 1 DAY)) --> Interval should be only day between two dates...\n(SELECT player_id, MIN(event_date) AS first_login \nFROM Activity  --> Only consider first active login date of user alias as first_login Using MIN function...\nGROUP BY player_id); --> Grouping w.r.t. player_id...\n# Approach\n<!-- Describe your approach to solving the problem. -->\nUsing Fundamentals of SQL...\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nSELECT ROUND(COUNT(DISTINCT player_id) / (SELECT COUNT(DISTINCT player_id) FROM Activity), 2) \nAS fraction \nFROM Activity\nWHERE (player_id, DATE_SUB(event_date, INTERVAL 1 DAY)) IN \n(SELECT player_id, MIN(event_date) AS first_login \nFROM Activity \nGROUP BY player_id);\n```
['Database', 'MySQL']