# 这里其实可以有很多不同的方法, 比如sum(case when submit_time is null then 1 else 0)
# sum(if(submit_time is null, 1, 0)) 都可以. 有没有大佬知道这些方法哪个效率更高?
select exam_id,
    count(start_time) - count(submit_time),
    round((count(start_time) - count(submit_time)) / count(1), 3)
from exam_record
group by exam_id
having count(start_time) - count(submit_time) > 0