<?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.kxs.user.biz.mapper.old.TradeDaySummaryMapper">


    <select id="currentMonthsPosTotal" resultType="java.math.BigDecimal">

        select IFNULL(SUM(HelpNonDirectTradeAmt + HelpNonDirectDebitTradeAmt + NotHelpNonDirectTradeAmt + NotHelpNonDirectDebitTradeAmt + ProfitNonDirectTradeAmt + ProfitNonDirectDebitTradeAmt),
                      0) as pos
        from TradeDaySummary pos
        where pos.UserId = #{userId}
          and pos.TradeMonth = #{queryMonth}
          and pos.SeoTitle = 'team'
        group by pos.TradeMonth

    </select>
    <select id="currentMonthsPosTotal2" resultType="java.math.BigDecimal">
        select IFNULL(SUM(ProfitTradeAmt + ProfitDebitTradeAmt), 0) as posAmount2
        from TradeDaySummary2
        where UserId = #{userId}
          and TradeMonth = #{queryMonth}
          and SeoTitle = 'team'
        GROUP BY TradeMonth
    </select>
    <select id="currentMonthsGdTotal" resultType="java.lang.Integer">
        select IFNULL(SUM(ActiveBuddyMerStatus), 0) as gdCount
        from UserTradeMonthSummary
        where UserId = #{userId}
          and SeoTitle = 'team'
          and BrandId = 14
        GROUP BY UserId
    </select>
    <select id="currentMonthsZlbTotal" resultType="java.math.BigDecimal">
        select IFNULL(SUM(TradeAmount), 0) as zlb
        from HelpProfitUserTradeSummay
        where UserId = #{userId}
          and TradeMonth = #{queryMonth}
          and SeoTitle = 'team'
        GROUP BY TradeMonth
    </select>
</mapper>
