LAG and RANK
\nWITH temp AS(\n\tSELECT player_id,\n\tevent_date - LAG(event_date, 1) OVER (PARTITION BY player_id ORDER BY event_date) AS difference, \n\tRANK() OVER (PARTIT
```\nWITH temp AS(\n\tSELECT player_id,\n\tevent_date - LAG(event_date, 1) OVER (PARTITION BY player_id ORDER BY event_date) AS difference, \n\tRANK() OVER (PARTITION BY player_id ORDER BY event_date) as rn\n\tFROM activity\n),\n\ntp AS\n(\n\tSELECT count(distinct(player_id)) as all_players\n\tFROM activity\n)\n\nSELECT ROUND(count(t.player_id)/tp.all_players,2) AS fraction\n\n\tFROM temp t\n\tJOIN tp\n\nWHERE t.rn = 2\nAND t.difference = 1\n```
[]