Skip to content

Commit fa3421d

Browse files
authored
Create game-play-analysis-v.sql
1 parent 11a1c15 commit fa3421d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

MySQL/game-play-analysis-v.sql

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Time: O(n^2)
2+
# Space: O(n)
3+
4+
SELECT install_dt,
5+
Count(player_id) AS installs,
6+
Round(Count(next_day) / Count(player_id), 2) AS Day1_retention
7+
FROM (SELECT a.player_id,
8+
a.install_dt,
9+
b.event_date AS next_day
10+
FROM (SELECT player_id,
11+
Min(event_date) AS install_dt
12+
FROM activity
13+
GROUP BY player_id) AS a
14+
LEFT JOIN activity AS b
15+
ON Datediff(b.event_date, a.install_dt) = 1
16+
AND a.player_id = b.player_id ) AS t
17+
GROUP BY install_dt;

0 commit comments

Comments
 (0)