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

 

 

select up.device_id, '复旦大学' as university,
    count(question_id) as question_cnt,
    sum(if(qpd.result='right', 1, 0)) as right_question_cnt
from user_profile as up

left join question_practice_detail as qpd
  on qpd.device_id = up.device_id and month(qpd.date) = 8

where up.university = '复旦大学'
group by up.device_id

 

select  u.device_id, u.university,
        count(q.question_id) as question_cnt,
        sum(if(q.result='right', 1, 0)) as right_question_cnt

from user_profile u
left join question_practice_detail q
on u.device_id = q.device_id and month(date) = 8

where u.university = '复旦大学'
group by u.device_id

 

posted on 2022-11-15 20:40  HHHuskie  阅读(22)  评论(0编辑  收藏  举报

导航