<?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.xinelu.manage.mapper.evaluateresult.EvaluateResultMapper">
    <resultMap type="com.xinelu.manage.vo.evaluateresult.EvaluateResultVo" id="EvaluateResult">
        <result property="count" column="t"/>
        <result property="evaluateResult" column="evaluate_result"/>
    </resultMap>

    <select id="list" parameterType="String" resultMap="EvaluateResult">
        select count(1) t,er.evaluate_result
        from patient_info pi
        left join evaluate_record er
        on pi.id = er.user_id
        <where>
        <if test="sex != null  and sex != ''">
            and pi.sex = #{sex}
        </if>
        <if test="startTime != null  and startTime != '' and endTime != null  and endTime != ''">
            and pi.birth_date BETWEEN #{startTime} and #{endTime}
        </if>
        </where>
        group by er.evaluate_result
    </select>
</mapper>
