<?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.malk.pake.mapper.PkWbcgMapper">

    <select id="selectSumDataList" resultType="java.util.Map" parameterType="java.lang.String">
          SELECT
            `SUBJECT`,
            ROUND(SUM(amt1),2) amt1,
            ROUND(SUM(amt2),2) amt2,
            ROUND(SUM(amt3),2) amt3,
            ROUND(SUM(amt4),2) amt4,
            ROUND(SUM(amt5),2) amt5,
            ROUND(SUM(amt6),2) amt6,
            ROUND(SUM(amt7),2) amt7,
            ROUND(SUM(amt8),2) amt8,
            ROUND(SUM(amt9),2) amt9,
            ROUND(SUM(amt10),2) amt10,
            ROUND(SUM(amt11),2) amt11,
            ROUND(SUM(amt12),2) amt12,
            ROUND(SUM(total),2) total,
            ROUND(SUM(ysamt1),2) ysamt1,
            ROUND(SUM(ysamt2),2) ysamt2,
            ROUND(SUM(ysamt3),2) ysamt3,
            ROUND(SUM(ysamt4),2) ysamt4,
            ROUND(SUM(ysamt5),2) ysamt5,
            ROUND(SUM(ysamt6),2) ysamt6,
            ROUND(SUM(ysamt7),2) ysamt7,
            ROUND(SUM(ysamt8),2) ysamt8,
            ROUND(SUM(ysamt9),2) ysamt9,
            ROUND(SUM(ysamt10),2) ysamt10,
            ROUND(SUM(ysamt11),2) ysamt11,
            ROUND(SUM(ysamt12),2) ysamt12,
            ROUND(SUM(ystotal),2) ystotal,
            ROUND(SUM(ndystotal),2) ndystotal
        FROM
            `pake_wbcg`
        <where>
            <if test="dept1 != null and dept1 != ''">
                AND dept1 LIKE '%' #{dept1} '%'
            </if>
            <if test="dept1 == null || dept1 == ''">
                AND (dept1="默认" || `no` !="02")
            </if>
            <if test="dept2 != null and dept2 != ''">
                AND dept2 LIKE '%' #{dept2} '%'
            </if>
        </where>
        GROUP BY
            `no`,`SUBJECT`
        ORDER BY `no`
    </select>
</mapper>