题解 | 统计复旦用户8月练题情况,你这不纯小丑了

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

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


select u.device_id,university,count(question_id) question_cnt,count(case when q.result like "right" then 1 end)right_question_cnt
from user_profile u left join question_practice_detail q
on u.device_id = q.device_id
#注意先进行连接之后再筛选学校和日期,若and放在where之前,则会导致连接时把不是八月份的数据剔除,从而使得连接后的表没有八月份之外的数据,例如九月份的数据被提前剔除了
where  university = "复旦大学"
and date like "2021-08%"
group by u.device_id

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务