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

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

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

select up.device_id,up.university,t.question_cnt,t.right_question_cnt
from user_profile up
right join
(
  select device_id,
  count( question_id) as question_cnt,
  sum(if(result='right',1,0)) as right_question_cnt
  from question_practice_detail
  group by device_id
) t
on up.device_id = t.device_id
where up.university = '复旦大学'

子查询先统计答题数量,以及答对的数量,然后进行关联查询,where查询

全部评论

相关推荐

被加薪的哈里很优秀:应该继续招人,不会给你留岗位的
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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