zoukankan      html  css  js  c++  java
  • sql case 与 sum

      <select id="selectTotal"  resultType="java.util.Map" parameterType="java.util.Map" statementType="STATEMENT">
       SELECT
        SUM(CASE way WHEN 'ZFB' THEN money_amount ELSE 0 END )  ZFBSUM,
        SUM(CASE way WHEN 'ZFBWAP' THEN money_amount ELSE 0 END )  ZFBWAPSUM,
        SUM(CASE way WHEN 'WX' THEN money_amount ELSE 0 END )  WXSUM,
        SUM(CASE way WHEN 'WXWAP' THEN money_amount ELSE 0 END )  WXWAPSUM,
    
        SUM(CASE way WHEN 'ZFB' THEN 1 ELSE 0 END )  ZFB,
        SUM(CASE way WHEN 'ZFBWAP' THEN 1 ELSE 0 END )  ZFBWAP,
        SUM(CASE way WHEN 'WX' THEN 1 ELSE 0 END )  WX,
        SUM(CASE way WHEN 'WXWAP' THEN 1 ELSE 0 END )  WXWAP
        FROM ${tableName} WHERE the_super_id = '${the_super_id}';
    
      </select>
    Map<String, Long> re = sqlSession.selectOne(MybatisNamespace.ordersTemp_selectTotal, param);
    
    Map<String, String> foIn = new LinkedHashMap<>();
    foIn.put("tId", tId);
    foIn.put("ZFBSUM", re.get("ZFBSUM") + "");
    foIn.put("ZFBWAPSUM", re.get("ZFBWAPSUM") + "");
    foIn.put("WXSUM", re.get("WXSUM") + "");
    foIn.put("WXWAPSUM", re.get("WXWAPSUM") + "");
    foIn.put("ZFB", re.get("ZFB") + "");
    foIn.put("ZFBWAP", re.get("ZFBWAP") + "");
    foIn.put("WX", re.get("WX") + "");
    foIn.put("WXWAP", re.get("WXWAP") + "");
    foIn.put("remainder_update_time", new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date().getTime()));
  • 相关阅读:
    js获取数组,对象的真实长度
    http和https区别
    react调用setstate后发生了什么
    for in for of foreach及map的区别
    事件委托(事件代理)
    CSS隐藏元素的几种方法
    react一些扩展
    [软件构造]异常的捕获与自定义
    [软件构造]可能是笔记总结吧
    计算机系统大作业
  • 原文地址:https://www.cnblogs.com/LiuPan2016/p/8667880.html
Copyright © 2011-2022 走看看