MySQL Without JOIN, with Explanation
Solution:\n\n\nSELECT ROUND(COUNT(DISTINCT player_id) / (SELECT COUNT(DISTINCT player_id) FROM Activity),2) as fraction \nFROM Activity\nWHERE (player_id, DATE_
**Solution:**\n\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_login FROM Activity GROUP BY player_id)\n```\n\n\n**Explanation:**\n\n1. Select the first login date of every player. This will be used as subquery for condition in our main query.\n```\nSELECT player_id, MIN(event_date) as first_login FROM Activity GROUP BY player_id\n```\n\n2. Search only for same players but with event dates one day ahead of first login date (subtract 1 day from current to match with previous date, if available)\n```\nSELECT ...\nFROM Activity\nWHERE (player_id, DATE_SUB(event_date, INTERVAL 1 DAY)) \n```\n\n3. Count players which match WHERE condition in (2) and divide them by total number of distinct players in activity, round off to 2 decimal places.\n\n```\nSELECT ROUND(COUNT(DISTINCT player_id) / (SELECT COUNT(DISTINCT player_id) FROM Activity),2) as fraction \n```
[]