要返回多个sum用map,一个就用int
Map<String, Object> getStatistics(@Param("shopId") String shopId, String orderName);
<select id="getStatistics" resultType="java.util.HashMap">
SELECT SUM(status=1) as status,SUM(money) as money,SUM(back_money) as backMoney,SUM(rate_Money) as rateMoney
FROM ${orderName}
<where>
<if test="shopId != null">
and shop_id=#{shopId}
</if>
<if test="beginTime != null">
and o.create_time >= #{beginTime}
</if>
<if test="endTime != null">
and #{endTime} >= o.create_time
</if>
</where>
</select>
这个是单个sum求和
Integer getStatistics(@Param("shopId") String shopId, String orderName);
<select id="getStatistics" resultType="java.lang.Integer">
select sum(money) as money
from ${orderName}where shop_id=#{shopId}
</select>
日常记录工作遇见的不愉快