Focus on retrieving first date
Intuition\nwe have to focus on to retrieve  first date only from table\n\n# Approach\nok, to get the first  date , we can do it by giving each player id -> the 
# Intuition\nwe have to focus on to retrieve  first date only from table\n\n# Approach\nok, to get the first  date , we can do it by giving each player id -> the row number , can will choose only first row and second row and will see if differnce is 1 , this will be long process,\n\nso we will retrieve the first  date with min (event date) and check our table\'s date , and divide by distinct id\'s\n\n# Complexity\n- Time complexity:\nO(n)\n\n\n# Code\n```mssql []\nSELECT\n    ROUND(\n        CAST(\n            SUM(\n                CASE WHEN DATEDIFF(day, b.event_date,a.event_date ) = 1 \n                THEN 1 ELSE 0 END\n                ) AS FLOAT\n            ) \n    /\n     COUNT(distinct b.player_id)\n    , 2) AS fraction\nFROM\n    Activity a\nINNER JOIN (\n    SELECT player_id, MIN(event_date) AS event_date\n    FROM Activity\n    GROUP BY player_id\n) b ON a.player_id = b.player_id;\n```
['MS SQL Server']