Sql综合练习-统计复旦用户8月练题情况

现在运营想要了解复旦大学的每个用户在8月份练习的总题目数和回答正确的题目数情况,请取出相应明细数据,对于在8月份没有练习过的用户,答题数结果返回0。

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
上一篇:【学习笔记】Python 使用 matplotlib 画图


下一篇:拉索回归(Lasso)算法原理讲解