代码拉取完成,页面将自动刷新
# $550. 游戏玩法分析 IV
# https://leetcode-cn.com/problems/game-play-analysis-iv/
# SQL架构
Create table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int);
Truncate table Activity;
insert into Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-03-01', '5');
insert into Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-03-02', '6');
insert into Activity (player_id, device_id, event_date, games_played) values ('2', '3', '2017-06-25', '1');
insert into Activity (player_id, device_id, event_date, games_played) values ('3', '1', '2016-03-02', '0');
insert into Activity (player_id, device_id, event_date, games_played) values ('3', '4', '2018-07-03', '5');
# Write your MySQL query statement below
select
round(avg(a.event_date is not null), 2) as fraction
from
(
select
player_id,
min(event_date) as login
from
Activity
group by
player_id
) tmp
left join Activity a on tmp.player_id = a.player_id
and datediff(a.event_date, tmp.login) = 1;
# clean-up
drop table Activity;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。