<?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.kcim.dao.mapper.HospProfitAndLossMapper">


    <select id="getPageList" resultType="com.kcim.dao.model.HospProfitAndLoss">
        select id          as id,
               date_year   as dateYear,
               date_month  as dateMonth,
               report_num  as reportNum,
               report_name as reportName,
               sum(amount) as amount,
               percent as percent,
               responsibility_code as responsibilityCode,
               responsibility_name as responsibilityName
        from cost_hosp_profit_and_loss
        where date_year = #{year}
          and date_month = #{month}
          and hosp_id = #{hospId}
          and delete_time = 0
        group by report_num
            limit #{startIndex}, #{pageSize}
    </select>
    <select id="getPageCount" resultType="java.lang.Integer">
        select count(*)
        from (
                 select *
                 from cost_hosp_profit_and_loss
                 where date_year = #{year}
                   and date_month = #{month}
                   and hosp_id = #{hospId}
                   and delete_time = 0
                 group by report_num) t
    </select>
</mapper>