<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qmth.jkserver.dao.ExamStudentAdditionalDao">

    <delete id="deleteByExamCode">
        delete t from jk_exam_student_additional t
        <where>
            <if test="examCode != null and examCode != ''">
                and t.exam_code = #{examCode}
            </if>
        </where>
    </delete>

    <select id="findByExamCode" resultType="com.qmth.jkserver.model.ExamStudentAdditional">
        select * from jk_exam_student_additional t
        <where>
            <if test="examCode != null and examCode != ''">
                and t.exam_code = #{examCode}
            </if>
        </where>
    </select>

    <select id="findDistinctStudent" resultType="java.util.Map">
        select t.exam_code as examCode,t.student_id as studentId,count(1) as count from jk_exam_student_additional t
        <where>
            <if test="examCode != null and examCode != ''">
                and t.exam_code = #{examCode}
            </if>
        </where>
        group by t.exam_code,t.student_id
        order by t.student_id
    </select>

    <select id="findByExamCodeByPage" resultType="java.util.Map">
        select t.course_code as courseCode,t.course_name as courseName,count(1) as count from jk_exam_student_additional t
        <where>
            <if test="examCode != null and examCode != ''">
                and t.exam_code = #{examCode}
            </if>
        </where>
        group by t.course_code,t.course_name
        order by t.course_code
    </select>

    <select id="findByExamCodeAndStudentId" resultType="com.qmth.jkserver.model.ExamStudentAdditional">
        select * from jk_exam_student_additional t
        <where>
            <if test="examCode != null and examCode != ''">
                and t.exam_code = #{examCode}
            </if>
        </where>
        order by t.student_id
    </select>

    <select id="findByExamCodeAndCourseCodeAndName" resultType="com.qmth.jkserver.model.ExamStudentAdditional">
        select * from jk_exam_student_additional t
        <where>
            <if test="examCode != null and examCode != ''">
                and t.exam_code = #{examCode}
            </if>
        </where>
        order by t.course_code
    </select>
</mapper>
