<?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.hzs.system.config.mapper.BdGradeMapper">

    <!-- 获取小于等于业绩最合适的等级 -->
    <select id="getLastGrade" resultType="com.hzs.common.domain.system.config.BdGrade">
        select t.*
        from (select bg.*
              from bd_grade bg
              where bg.del_flag = 0
                and bg.pk_country = #{pkCountry}
                and #{achieve} >= bg.start_value
              order by bg.start_value desc) t
        where rownum = 1
    </select>

</mapper>
