<?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="cn.com.ctop.alarm.modules.mapper.RuleAccountThresholdMapper">

    <select id="selectByAccountId" resultType="cn.com.ctop.alarm.modules.entity.RuleAccountThreshold">
       SELECT * FROM ctop_rule_account_threshold
       WHERE account_id = #{accountId}
       AND  (batch_no ='' or batch_no is null)
    </select>
    <select id="selectGroupIdsByAccountId" resultType="java.lang.Long">
       SELECT group_id FROM `ctop_rule_account_threshold`
        WHERE (batch_no !='' and batch_no is not null)
        and  account_id = #{accountId}
        group by group_id
    </select>
    <select id="selectbatchNosByGroupIdId" resultType="java.lang.String">
       SELECT batch_no FROM `ctop_rule_account_threshold`
        WHERE  (batch_no !='' and batch_no is not null)
        and account_id = #{accountId}
        and group_id = #{groupId}
        GROUP BY batch_no
    </select>
    <select id="selectCopyThresholdByAccountId" resultType="cn.com.ctop.alarm.modules.entity.RuleAccountThreshold">
       SELECT * FROM ctop_rule_account_threshold
        WHERE account_id = #{accountId}
        and group_id = #{groupId}
        and batch_no = #{batchNo}
    </select>

    <select id="getBatchNo" resultType="java.lang.String">
    select batch_no from ctop_rule_account_threshold
    where  account_id = #{accountId}
    and group_id = #{groupId}
    and (batch_no !='' and batch_no is not null)
    group by batch_no
    </select>
</mapper>