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

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

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

判断条件,学校是复旦大学。统计8月和非8月的答题量和正确率,分别对月份和是否正确进行条件判断函数,8月计1,非8月计0,相加。正确计1,非正确计0,相加。按照device_id进行分组统计。
select a.device_id,a.university,sum(case month(date) when 8 then 1 else 0 end) as question_cnt,
sum(case when result ='right' then 1 else 0 end ) as right_question_cnt
from user_profile as a
left join
question_practice_detail as b
on a.device_id=b.device_id
where a.university='复旦大学'
group by a.device_id

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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