Easiest Intuition | How to think / approach | Nested Query
Intuition\n Describe your first thoughts on how to solve this problem. \n\nDon\'t look at SELECT in the code, the main logic resides in FROM...WHERE.\n\nLOGIC: 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\nDon\'t look at `SELECT` in the code, the main logic resides in `FROM...WHERE`.\n\nLOGIC: **Pick those rows whose date is 1 more than min date of that player id**\n\nSuppose you could find min date as x, the sql code to pick those rows would be:\n```mysql\nSELECT *\nFROM Activity \nWHERE DATEDIFF(event_date, x) = 1\n```\n\nHow to find x? That\'s implemented in the **nested query**.\nThen the question is about writting appropriate math calculations in `SELECT` .\n\n*I hope you could get some intuition on how to think in such questions, cheers! \uD83E\uDD42*\n\n# Code\n```mysql []\n# Write your MySQL query statement below\n\nSELECT IFNULL(ROUND( SUM(a1.games_played!=0) / ( \n    SELECT COUNT( DISTINCT player_id) FROM Activity\n) , 2) , 0) AS fraction\nFROM Activity a1\nWHERE DATEDIFF(event_date , (\n    SELECT MIN(event_date) FROM Activity a2\n    WHERE a1.player_id = a2.player_id\n)) = 1;\n```
['Database', 'MySQL']