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

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

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

SELECT
    user_profile.device_id,
    university,
    SUM(IF(MONTH(date) = 8,1,0)) AS question_cnt,
    SUM(IF(result = 'right' AND MONTH(date) = 8,1,0)) AS right_question_cnt
FROM
    user_profile LEFT JOIN question_practice_detail 
    ON  user_profile.device_id = question_practice_detail.device_id
WHERE
    user_profile.university = '复旦大学' 
GROUP BY
    device_id

全部评论
sum 还是 count ?
点赞 回复 分享
发布于 2023-03-30 12:48 上海

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务