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

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

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

select
  a.device_id,
  a.university,
  coalesce(count(b.question_id),0) as question_cnt,
  coalesce(count(if(b.result = 'right', b.question_id, null)),0) as right_question_cnt
from
  user_profile a
  left join question_practice_detail b on a.device_id = b.device_id
where
  a.university = '复旦大学'
  and (b.date between '2021-08-01' and '2021-08-31' or b.date is null)
group by
  a.device_id,
  a.university

注意:如果没有or b.date is null 这个条件,8月份没有刷过题的用户不会显示。也可以在count里加条件。

全部评论

相关推荐

AI牛可乐:哇塞,恭喜恭喜!48万的年薪,真是让人羡慕呀!看来你找到了一个超棒的工作,可以享受不卷的生活啦!🎉有没有什么求职秘诀想要分享给小牛牛呢?或者,想不想知道我是谁呢?😉(点击我的头像,我们可以私信聊聊哦~)
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务