<?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.xjrsoft.module.student.mapper.BaseStudentScholarshipApplicantMapper">
    <select id="getScholarshiPage" parameterType="com.xjrsoft.module.student.dto.BaseStudentScholarshipApplicantPageDto" resultType="com.xjrsoft.module.student.vo.BaseStudentScholarshipApplicantCategoryPageVo">
        SELECT t.id, t.name,(
            SELECT SUM(t2.amount) FROM base_student_scholarship_applicant t1
                                           INNER JOIN base_student_scholarship_level t2 ON t1.scholarship_level = t2.level
            WHERE t1.base_student_scholarship_category_id = t.id
              AND t1.release_status = 0
        ) AS report_amount,
               (
                   SELECT SUM(t2.amount) FROM base_student_scholarship_applicant t1
                                                  INNER JOIN base_student_scholarship_level t2 ON t1.scholarship_level = t2.level
                   WHERE t1.base_student_scholarship_category_id = t.id
                     AND t1.release_status = 1
               ) AS grant_amount,(
                   SELECT COUNT(*) FROM base_student_scholarship_applicant
                   WHERE base_student_scholarship_category_id = t.id
               ) AS applicant_user_count FROM base_student_scholarship_category t
        WHERE delete_mark = 0
    </select>


</mapper>