where t.exam_id=#{query.examId} AND t.status in #{st} and t.exam_status=#{query.examStatus} and t.exam_number =#{query.examNumber} and t.name=#{query.name} and t.package_code=#{query.packageCode} and t.campus_name=#{query.campusName} and t.campus_code=#{query.campusCode} and t.subject_code=#{query.subjectCode} and t.exam_site=#{query.examSite} and t.exam_room=#{query.examRoom} and t.province=#{query.province} and t.absent_suspect=#{query.absentSuspect} and t.omr_absent=#{query.omrAbsent} and t.assigned=#{query.assigned} and t.incomplete=#{query.incomplete} and t.question_filled=#{query.questionFilled} and t.subjective_filled=#{query.subjectiveFilled} and t.device=#{query.device} and t.assigned_check_count=#{query.assignedCheckCount} and t.assigned_suspect=#{query.assignedSuspect} and t.paper_type!='#' and t.paper_type!='?' and t.paper_type='#' and t.paper_type='?' select #{query.groupType} groupType, t.${groupNameCol} groupName, count(1) totalCount, sum(case when t.status='SCANNED' then 1 else 0 end) scannedCount, sum(case when t.status='UNEXIST' then 1 else 0 end) unexistCount, sum(case when t.status='MANUAL_ABSENT' then 1 else 0 end) manualAbsentCount, sum(case when t.omr_absent=1 then 1 else 0 end) omrAbsentCount, sum(case when t.absent_suspect=1 then 1 else 0 end) absentSuspectCount from sc_student t where t.exam_id=#{query.examId} and t.${groupNameCol} is not null and t.campus_code=#{query.campusCode} and t.subject_code=#{query.subjectCode} and t.exam_site=#{query.examSite} and t.exam_room=#{query.examRoom} group by t.${groupNameCol} where 1=1 and (1=2 or tem.unexistCount>0 or tem.manualAbsentCount>0 or tem.omrAbsentCount>0 or tem.absentSuspectCount>0 ) and tem.scannedCount>0 and tem.scannedCount=0 order by tem.groupName UPDATE sc_student SET assigned_check_count = (SELECT count(1) FROM sc_assigned_check_history h WHERE h.student_id = #{id}) WHERE id = #{id} where t.exam_id=#{query.examId} AND t.status in #{st} AND t.exam_status in #{st} and t.exam_number in #{en} and t.name=#{query.name} and t.package_code=#{query.packageCode} and t.campus_name=#{query.campusName} and t.campus_code=#{query.campusCode} and t.subject_code=#{query.subjectCode} and t.exam_site=#{query.examSite} and t.exam_room=#{query.examRoom} and t.province=#{query.province} and t.absent_suspect=#{query.absentSuspect} and t.omr_absent=#{query.omrAbsent} and t.assigned=#{query.assigned} and t.incomplete=#{query.incomplete} and t.question_filled=#{query.questionFilled} and t.subjective_filled=#{query.subjectiveFilled} and t.device=#{query.device} and t.assigned_check_count=#{query.assignedCheckCount} and t.assigned_suspect=#{query.assignedSuspect} and t.paper_type!='#' and t.paper_type!='?' and t.paper_type='#' and t.paper_type='?' and (t.question_filled=1 or t.subjective_filled=1) and t.question_filled=0 and t.subjective_filled=0