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

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

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

select user_profile.device_id,university,count(question_id) as question_cnt,
sum(case when question_practice_detail.result = 'right' then 1 else 0 end) as right_question_cnt from user_profile
left join question_practice_detail on user_profile.device_id = 
question_practice_detail.device_id
where university = '复旦大学' and (month(date) = 8 or date is null) 
group by device_id

sum(case when question_practice_detail.result = 'right' then 1 else 0 end) 这一部分是抄的答案 查答案是正确的题数量

我先考虑到对id分组 但是分组之前可以先用where 搜大学和时间

还有一个易错点是第一个搜索词select user_profile.device_id 这个地方前面只能是user_profile 不能是question_practice_detail

全部评论

相关推荐

写不来代码的小黑:这么小的城市能有做it的公司也不容易
点赞 评论 收藏
分享
07-29 14:57
门头沟学院 Java
复盘中的钝角很想踢足...:别说ppt了,我简历去面试都不带的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务