if(*判断条件*,*满足返回*,*不满足返回*)
count()计数,无论数值多少,计数+1
sum()总数,计算数值总和
select t1.device_id, university, count(date)qusetion_cnt, sum(if(t2.result = 'right',1,0))right_question_cnt from user_profile t1 left join question_practice_detail t2 on t1.device_id = t2.device_id and date like '2021-08%' where university = '复旦大学' group by t1.device_id