题解 | #月均完成试卷数不小于3的用户爱作答的类别#

月均完成试卷数不小于3的用户爱作答的类别

http://www.nowcoder.com/practice/b1d13efcfa0c4ecea517afbdb9090845

感觉自己写的乱七八遭,运行效率还不错…… 另外,牛客网这题目就不能出的没有疑义吗?月均数>=3搞得我以为每个月都要>=3

-- 1,查询出uid,tag,month,完成情况
-- 2,找出月均完成大于等于3的用户
-- 3,统计这些用户的类别情况(包括没完成的)

with tmp as-- 统计每个用户每个月的完成数
(
select uid,mon,sum(compl)as total from
(select uid,tag,month(start_time)as mon,if(submit_time is null,0,1)as compl 
from exam_record 
left join examination_info 
using(exam_id)
 )c
 group by uid,mon
 )
select tag,count(tag)as tag_cnt from examination_info ei
join exam_record er
on er.uid in (select distinct uid from tmp where total>=3) and ei.exam_id=er.exam_id
group by tag
order by tag_cnt desc

全部评论
是啊,我也以为每个月都要大于等于3
点赞 回复 分享
发布于 2022-04-24 15:42

相关推荐

在秋招的小白菜很想养修勾:一眼 苍穹外卖+谷粒商城,项目换一换吧,可以找一些付费知识星球博主带带,避免烂大街。多投投大厂,背背八股,你这学历乱杀了,等实习经验到位,到时候大厂闭眼选
投递美团等公司7个岗位
点赞 评论 收藏
分享
野猪不是猪🐗:我assume that你must技术aspect是solid的,temperament也挺good的,however面试不太serious,generally会feel style上不够sharp
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务