count(distinct(t.general_resources_question_snapshot_id)) as question_count,
sum(case when t.general_question_log_update_time is not null then 1 else 0 end) as finish_count,
sum(case when t.general_question_log_update_time is not null and t.question_score = t.student_score then 1 else 0 end) as success_count,
sum(case when t.general_question_log_update_time is not null and t.question_score <> t.student_score then 1 else 0 end) as error_count,
sum(case when t.general_question_log_update_time is not null and t.question_score = t.student_score then 1 else 0 end) / IF(count(distinct(t.general_resources_question_snapshot_id)) = 0, 1, count(distinct(t.general_resources_question_snapshot_id))) * 100 as success_rate,
sum(case when t.general_question_log_update_time is not null and t.question_score = t.student_score then t.question_score else ifnull(t.student_score, 0) end) as student_score,
sum(case when t.general_question_log_update_time is not null then 1 else 0 end) / IF(count(distinct(t.general_resources_question_snapshot_id)) = 0, 1, count(distinct(t.general_resources_question_snapshot_id))) finish_progress
from
general_question_log t
left join general_resources_question_snapshot tc on tc.general_resources_question_snapshot_id = t.general_resources_question_snapshot_id
left join student ta on ta.student_id = t.student_id and ta.student_status = 1
left join school_class tb on tb.class_id = ta.class_id and tb.class_status = 1
where
1 = 1
and t.general_question_setting_id = #generalQuestionSettingId#
@if(!isEmpty(courseInfoId)){
and tc.business_course_info_id = #courseInfoId#
@}
@if(!isEmpty(studentOrName)){
and (ta.student_name like #'%'+studentOrName+'%'# or ta.student_sn like #'%'+studentOrName+'%'#)