select up.device_id, up.university, coalesce(count(up.device_id),0), coalesce(count(case when qpd.result = 'right' then 1 end),null) from user_profile up left join question_practice_detail qpd on up.device_id = qpd.device_id where qpd.date like "2021-08%" and up.university = "复旦大学" group by device_id

京公网安备 11010502036488号