力扣高频SQL50题(基础版)——第八天
1 游戏玩法分析 IV
1.1 题目内容
1.1.1 基本题目信息
1.1.2 示例输入输出
1.2 示例sql语句
SELECT ROUND(count(a2.f_date)/(SELECT count(distinct player_id) FROM Activity),2) fraction
FROM Activity a1
INNER JOIN
(
SELECT player_id,MIN(event_date) f_date
FROM Activity
GROUP BY player_id
)a2
ON a1.player_id=a2.player_id AND a1.event_date-a2.f_date=1
1.3 运行截图
2 每位教师所教授的科目种类的数量
2.1 题目内容
2.1.1 基本题目信息
2.1.2 示例输入输出
2.2 示例sql语句
SELECT teacher_id,count(distinct subject_id) cnt
FROM Teacher
GROUP BY teacher_id
2.3 运行截图
3 查询近30天活跃用户数
3.1 题目内容
3.1.1 基本题目信息
3.1.2 示例输入输出
3.2 示例sql语句
SELECT activity_date day,count(distinct user_Id) active_users
FROM Activity
WHERE activity_date BETWEEN DATE_SUB('2019-07-27',INTERVAL 29 day) AND '2019-07-27'
GROUP BY activity_date
3.3 运行截图