首页
题库
公司真题
专项练习
面试题库
在线编程
面试
面试经验
AI 模拟面试
简历
求职
学习
基础学习课
实战项目课
求职辅导课
专栏&文章
竞赛
我要招人
发布职位
发布职位、邀约牛人
更多企业解决方案
AI面试、笔试、校招、雇品
HR免费试用AI面试
最新面试提效必备
登录
/
注册
无上清颜
获赞
1361
粉丝
2
关注
14
看过 TA
105
男
门头沟学院
2023
数据分析师
IP属地:山东
摸鱼界扛把子
私信
关注
拉黑
举报
举报
确定要拉黑无上清颜吗?
发布(63)
评论
刷题
收藏
无上清颜
关注TA,不错过内容更新
关注
2021-11-22 10:30
门头沟学院 数据分析师
题解 | #第二快/慢用时之差大于试卷时长一半的试卷#
注意:相差时长大于等于限定时长的一半 with t as (select t.exam_id, TIMESTAMPDIFF(MINUTE,start_time,submit_time) as time_gap, row_number()over(partition by exam_id order by TIMESTAMPDIFF(MINUTE,start_time,submit_time) desc) as rn1, row_number()over(partition by exam_id order by TIMESTAMPDIFF(MINUTE,start_time,submit_ti...
0
点赞
评论
收藏
分享
2021-11-20 11:00
门头沟学院 数据分析师
题解 | #每个6/7级用户活跃情况#
select * from (select tag,uid,ROW_NUMBER()over(partition by tag order by max(score) desc,min(score) desc,uid desc) as ranking from examination_info t join exam_record t1 on t.exam_id = t1.exam_id group by tag,uid) t1 where ranking <=3
0
点赞
评论
收藏
分享
2021-11-19 19:53
门头沟学院 数据分析师
题解 | #每个6/7级用户活跃情况#
层层击破 with t as ( select uid,start_time,submit_time,exam_id from exam_record union all select uid,submit_time as start_time,submit_time,question_id as exam_id from practice_record ) select t1.uid, case when t2.act_month_total is null then 0 else act_month_total end as act_month_total, case when t2.ac...
无上清颜:
练习逻辑思维的好题
0
点赞
评论
收藏
分享
2021-11-19 15:01
门头沟学院 数据分析师
题解 | #满足条件的用户的试卷完成数和题目练习数#
四个条件: 1.高难度SQL试卷平均分大于80 2.7级红名dalao 3.统计2021年 试卷完成数和题目练习数 4.只保留2021年有试卷完成记录的用户 select t.uid, count(distinct exam_id) as exam_cnt, count(distinct question_id,t1.submit_time) as question_cnt from exam_record t left join (select * from practice_record where year(submit_time)=2021) t1 on t.uid = t1.u...
0
点赞
评论
收藏
分享
2021-11-19 11:06
门头沟学院 数据分析师
题解 | #分别满足两个活动的人#
本题最大亮点就是TIMESTAMPDIFF函数 select * FROM (select uid,'activity1' as activity from exam_record where year(start_time)=2021 group by uid having min(score)>=85 UNION select distinct uid,'activity2' as activity from examin...
0
点赞
评论
收藏
分享
2021-10-31 10:35
门头沟学院 数据分析师
题解 | #作答试卷得分大于过80的人的用户等级分布#
SELECt level,count(1) as level_cnt from user_info t,examination_info t1,exam_record t2 where t.uid = t2.uid and t1.exam_id = t2.exam_id and tag='SQL' and score>80 group by level order by count(1) DESC
0
点赞
评论
收藏
分享
2021-12-08 10:56
已编辑
门头沟学院 数据分析师
不连表 就是玩儿
select exam_id,count(distinct uid) as uv,round(avg(score),1) as avg_score from exam_record where exam_id in (select exam_id from examination_info where tag = 'SQL') and uid in (select uid from user_info where level >5) and date(submit_time) in (select date(release_time) from examination_info wher...
风雪行:
你这个答案明显是错的,date(submit_time) in 子查询, 子查询需要添加exam_id相等的条件才可以, 不然都不是一一对应的时间
0
点赞
评论
收藏
分享
2021-10-30 09:54
门头沟学院 数据分析师
题解 | #平均活跃天数和月活人数#
# 第一步求出MAU和总活跃人数 不计天数重复 select date_format(start_time,"%Y%m") as month,round(count(distinct uid,date_format(start_time,"%Y%m%d"))/count(distinct uid),2),count(distinct uid) from exam_record where score is not null and year(start_time)=2021 group by month
0
点赞
评论
收藏
分享
2021-10-27 10:47
门头沟学院 数据分析师
题解 | #平均活跃天数和月活人数#
#该题的重点在于计算不同用户月活天数的总和,会有天数重复,要用distinct函数划分时间。另外,注意是2021年数据 select date_format(start_time,"%Y%m") as month, round(count(distinct uid,date_format(start_time,"%Y%m%d"))/count(distinct uid),2) as avg_active_days, # 计算月活平均天数, count(distinct uid) as mau # 计算月活人数 from exam_record where score is not null a...
归桂:
请问这个语句是什么意思呢 count(distinct uid,date_format(start_time,"%Y%m%d"))
0
点赞
评论
收藏
分享
2021-10-15 09:02
门头沟学院 数据分析师
属实有点绕
with t as ( select *,ROW_NUMBER()over(partition by job order by score desc) as t_rank,count(1)over(partition by job) as num from grade ) select id,job,score,t_rank from t where (id,t_rank) in (select id,case when mod(num,2)=1 then (num+1)/2 else num/2 end as 'rank' from t union select id,case when m...
0
点赞
评论
收藏
分享
2021-10-13 15:14
门头沟学院 数据分析师
题解 | #牛客每个人最近的登录日期(五)#
with t as ( select user_id,date,lead(date,1)over(partition by user_id) as dtime from login # where (user_id,date) in (select user_id,min(date) from login group by user_id) ) select distinct t2.date, case when rate is not null then rate else 0.000 end as p from (select date,round(sum(datediff(dtime,d...
0
点赞
评论
收藏
分享
2021-10-13 14:57
门头沟学院 数据分析师
题解 | #牛客每个人最近的登录日期(四)#
with t as ( select user_id,date from login where (user_id,date) in (select user_id,min(date) from login group by user_id) ) select t1.date,count(distinct t.user_id) as new from t right join login t1 on t.date = t1.date group by t1.date order by date
0
点赞
评论
收藏
分享
2021-10-13 14:56
门头沟学院 数据分析师
题解 | #牛客每个人最近的登录日期(四)#
with t as ( select user_id,date from login where (user_id,date) in (select user_id,min(date) from login group by user_id) ) select t1.date,count(distinct t.user_id) as new from t right join login t1 on t.date = t1.date group by t1.date order by date
0
点赞
评论
收藏
分享
2021-10-13 14:49
门头沟学院 数据分析师
逻辑易理解
#1.建立临时表,计算date+1 with t as ( select *,lead(date,1)over(partition by user_id order by date) as dtime from login ) #2.首先筛选出用户第一天登录的数据,再利用sum和datediff函数求出dtime和date相差为1的数据量 select round(sum(datediff(date,dtime)=-1)/count(distinct user_id),3) from t where (user_id,date) in (select user_id,min(date) fro...
0
点赞
评论
收藏
分享
2021-10-13 11:46
门头沟学院 数据分析师
逻辑相对清晰
# 创建临时表,筛出不符合条件的对象 with t as ( select * from email where send_id not in(select id from user where is_blacklist=1 ) and receive_id not in (select id from user where is_blacklist=1) ) # 根据日期做分组,算就完了 select date,round(sum(type='no_completed')/count(1),3) as p from t group by date
0
点赞
评论
收藏
分享
1
2
3
4
5
创作者周榜
更多
关注他的用户也关注了:
牛客网
牛客网在线编程
牛客网题解
牛客企业服务