题解 | #统计复旦用户8月练题情况#

统计复旦用户8月练题情况

https://www.nowcoder.com/practice/53235096538a456b9220fce120c062b3

-- 需要关联两张表,根据题目说没有练习过的用户,答题数结果返回0,所以我们用left join保全左边所有用户。
-- 限定条件:复旦大学 university='复旦大学',8月份练习,且答题正确result='right'

--需要根据用户分组 group by device_id。
select t1.device_id,t1.university,
count(t2.question_id) as question_cnt,
sum(if(t2.result='right',1,0)) as right_question_cnt
from user_profile as t1
left join question_practice_detail as t2
on t1.device_id = t2.device_id
where t1.university = '复旦大学' and (month(t2.date)='08'or month(t2.date) is null )
group by t1.device_id;

全部评论

相关推荐

一天代码十万三:实习东西太少了,而且体现不出你业务,3个月不可能就这点产出吧,建议实习多写点,玩具项目面试官都不感兴趣的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务