Skip to content

Commit e221be8

Browse files
authored
feat: add sql solution to lc problem: No.1097 (#1089)
No.1097.Game Play Analysis V
1 parent 129e6f3 commit e221be8

File tree

4 files changed

+61
-2
lines changed

4 files changed

+61
-2
lines changed

.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"solution/0600-0699/0610.Triangle Judgement/Solution.sql",
1818
"solution/0600-0699/0618.Students Report By Geography/Solution.sql",
1919
"solution/0600-0699/0626.Exchange Seats/Solution.sql",
20+
"solution/1000-1099/1097.Game Play Analysis V/Solution.sql",
2021
"solution/1000-1099/1098.Unpopular Books/Solution.sql",
2122
"solution/1100-1199/1113.Reported Posts/Solution.sql",
2223
"solution/1100-1199/1174.Immediate Food Delivery II/Solution.sql",

solution/1000-1099/1097.Game Play Analysis V/README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,26 @@ Result 表:
6666
### **SQL**
6767

6868
```sql
69-
69+
# Write your MySQL query statement below
70+
WITH
71+
t AS (
72+
SELECT
73+
player_id,
74+
event_date,
75+
min(event_date) OVER (PARTITION BY player_id) AS install_dt
76+
FROM Activity
77+
)
78+
SELECT
79+
install_dt,
80+
count(DISTINCT player_id) AS installs,
81+
round(
82+
sum(if(datediff(event_date, install_dt) = 1, 1, 0)) / count(
83+
DISTINCT player_id
84+
),
85+
2
86+
) AS day1_retention
87+
FROM t
88+
GROUP BY install_dt;
7089
```
7190

7291
<!-- tabs:end -->

solution/1000-1099/1097.Game Play Analysis V/README_EN.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,26 @@ Player 2 installed the game on 2017-06-25 but didn&#39;t log back in on 2017-06-
6666
### **SQL**
6767

6868
```sql
69-
69+
# Write your MySQL query statement below
70+
WITH
71+
t AS (
72+
SELECT
73+
player_id,
74+
event_date,
75+
min(event_date) OVER (PARTITION BY player_id) AS install_dt
76+
FROM Activity
77+
)
78+
SELECT
79+
install_dt,
80+
count(DISTINCT player_id) AS installs,
81+
round(
82+
sum(if(datediff(event_date, install_dt) = 1, 1, 0)) / count(
83+
DISTINCT player_id
84+
),
85+
2
86+
) AS day1_retention
87+
FROM t
88+
GROUP BY install_dt;
7089
```
7190

7291
<!-- tabs:end -->
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Write your MySQL query statement below
2+
WITH
3+
t AS (
4+
SELECT
5+
player_id,
6+
event_date,
7+
min(event_date) OVER (PARTITION BY player_id) AS install_dt
8+
FROM Activity
9+
)
10+
SELECT
11+
install_dt,
12+
count(DISTINCT player_id) AS installs,
13+
round(
14+
sum(if(datediff(event_date, install_dt) = 1, 1, 0)) / count(
15+
DISTINCT player_id
16+
),
17+
2
18+
) AS day1_retention
19+
FROM t
20+
GROUP BY install_dt;

0 commit comments

Comments
 (0)