select d.id, d.exam_id, d.repo_id, d.radio_count, d.radio_score, d.multi_count, d.multi_score, d.judge_count, d.judge_score, d.saq_count, d.saq_score ,(SELECT COUNT(0) FROM t_el_qu_repo WHERE repo_id=d.repo_id AND qu_type=1) AS totalRadio, (SELECT COUNT(0) FROM t_el_qu_repo WHERE repo_id=d.repo_id AND qu_type=2) AS totalMulti, (SELECT COUNT(0) FROM t_el_qu_repo WHERE repo_id=d.repo_id AND qu_type=3) AS totalJudge from t_el_exam_repo d SELECT seq_t_el_exam_repo.NEXTVAL as id FROM DUAL insert into t_el_exam_repo id, exam_id, repo_id, radio_count, radio_score, multi_count, multi_score, judge_count, judge_score, saq_count, saq_score, #{id}, #{examId}, #{repoId}, #{radioCount}, #{radioScore}, #{multiCount}, #{multiScore}, #{judgeCount}, #{judgeScore}, #{saqCount}, #{saqScore}, update t_el_exam_repo exam_id = #{examId}, repo_id = #{repoId}, radio_count = #{radioCount}, radio_score = #{radioScore}, multi_count = #{multiCount}, multi_score = #{multiScore}, judge_count = #{judgeCount}, judge_score = #{judgeScore}, saq_count = #{saqCount}, saq_score = #{saqScore}, where id = #{id} delete from t_el_exam_repo where id = #{id} delete from t_el_exam_repo where exam_id = #{examId} delete from t_el_exam_repo where id in #{id}