美文网首页
【MySQL】LeetCode 1097

【MySQL】LeetCode 1097

作者: 每天要读书的Claire | 来源:发表于2020-02-20 14:47 被阅读0次

1097 游戏玩法分析5

mysql> select * from activity;
+-----------+-----------+------------+--------------+
| player_id | device_id | event_date | games_played |
+-----------+-----------+------------+--------------+
|         1 |         2 | 2016-03-01 |            5 |
|         1 |         2 | 2016-03-02 |            6 |
|         2 |         3 | 2017-06-25 |            1 |
|         3 |         1 | 2016-03-01 |            0 |
|         3 |         4 | 2018-07-03 |            5 |
|         1 |         2 | 2016-08-03 |            4 |
+-----------+-----------+------------+--------------+
6 rows in set (0.01 sec)
求每天(若有)的 new install数 以及 次日留存率
select install_date,
count(player_id)as installs ,
count(event_date)/count(player_id) as Day1_retention 
from 
(select T1.player_id,
T1.install_date,
T2.event_date 
from (select player_id,
min(event_date) as install_date 
from activity
group by player_id) T1
left join activity T2
on T1.player_id=T2.player_id
and T1.install_date+1=T2.event_date)A
group by install_date ;
+--------------+----------+----------------+
| install_date | installs | Day1_retention |
+--------------+----------+----------------+
| 2016-03-01   |        2 |         0.5000 |
| 2017-06-25   |        1 |         0.0000 |
+--------------+----------+----------------+
2 rows in set (0.00 sec)

相关文章

  • 【MySQL】LeetCode 1097

    1097 游戏玩法分析5

  • Leetcode 1097. 游戏玩法分析 V

    https://leetcode-cn.com/problems/game-play-analysis-v/[ht...

  • LeetCode之database(MySQL)

    在MySQL数据库中建立一个名为leetcode的数据库:mysql>create database if not...

  • 1097

    观自在菩萨,行深般若波罗蜜多时,照见五蕴皆空,度一切苦厄,舍利子,色不异空,空不异色。色即是空,空即是色。受想行识...

  • 1097

    9月26日,农历九月初一,多云,周一 打算吃过晚饭出去晃晃,结果坐下来,就懒得挪动位置。娃爸不在家吃饭,我就不用开...

  • Leetcode1097.游戏玩家分析V(困难)

    题目Activity 活动记录表 (player_id,event_date)是此表的主键这张表显示了某些游戏的玩...

  • 就业班第一周总结

    这一周主要学习了MySQL基本知识与部分python基本知识。 通过MySQL45题与leetcode题目巩固基本...

  • LeetCode-mysql练习题

    leetcode-mysql练习题总结: 老师指路->https://www.jianshu.com/u/989c...

  • 2020-04-21

    1097 Deduplication on a Linked List (25分) Given a singly ...

  • 2020-12-27

    Georgia Reports 1097 New Cases of Coronavirus, 25 Deaths ...

网友评论

      本文标题:【MySQL】LeetCode 1097

      本文链接:https://www.haomeiwen.com/subject/sdotqhtx.html