已完成的试卷数可以用一个子查询把未完成的卷子筛掉,然后count就行了

select

count(id) total_pv,

count(submit_time) complete_pv,

(select count(distinct exam_id) from exam_record b where b.submit_time is not null) complete_exam_cnt

from exam_record a