Mybatis查询每天的整车和散件总计同时,查询散件运费总计

通过case when提前查询部分统计信息

  <resultMap type="com.entity.N25175Goods" id="gdCount">
      <result column="date"  property="date"  />
    <result column="inCount" property="inCount"/><!-- 总收入 -->
    <result column="chargeCount" property="chargeCount"/><!-- 总取件费 -->
    <result column="feeCount" property="feeCount" /><!-- 总派件费 -->
    <result column="sanjianCount" property='sanjianCount'/><!-- 总散件运费 -->
    <result column="zhengcheCount" property="zhengcheCount"/><!-- 总整车运费 -->
  </resultMap>
  
  
  <select id="selectRevenueStatistic" resultMap="gdCount">
  select  DATE_FORMAT(gd_ctime, '%Y-%m-%d') AS date, 
  SUM(gd_total) AS inCount, <!-- 总收入 -->
  SUM(gd_charge) as chargeCount,<!-- 总取件费 -->
  SUM(gd_fee) as feeCount, <!-- 总派件费 -->
  SUM(CASE when gd_type=0 then gd_freight else 0 end) as sanjianCount,<!-- 散件运费 -->
  SUM(CASE when gd_type=3 then gd_freight else 0 end) as zhengcheCount<!-- 整车运费 -->
  from n25175_goods
  <if test="dateStart!=null and dateEnd!=null">
   where gd_ctime between #{dateStart} and #{dateEnd}
  </if>
  group by DATE_FORMAT(gd_ctime, '%Y-%m-%d')
  </select>  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值