• 数据库多行转一行


     SELECT  max(case sys_date when '20181019' then amount end) as trade_settle_amount0, max(case sys_date when '20181019' then number end) as trade_settle_number0, max(case sys_date when '20181018' then amount end) as trade_settle_amount1,  max(case sys_date when '20181018' then number end) as trade_settle_number1, max(case sys_date when '20181017' then amount end) as trade_settle_amount2,  max(case sys_date when '20181017' then number end) as trade_settle_number2, max(case sys_date when '20181016' then amount end) as trade_settle_amount3,  max(case sys_date when '20181016' then number end) as trade_settle_number3, max(case sys_date when '20181015' then amount end) as trade_settle_amount4,  max(case sys_date when '20181015' then number end) as trade_settle_number4, max(case sys_date when '20181014' then amount end) as trade_settle_amount5,  max(case sys_date when '20181014' then number end) as trade_settle_number5, max(case sys_date when '20181013' then amount end) as trade_settle_amount6,  max(case sys_date when '20181013' then number end) as trade_settle_number6, max(case sys_date when 'total' then amount end) as trade_settle_amount7,  max(case sys_date when 'total' then number end) as trade_settle_number7  from  (SELECT sys_date,sum(trans_amount) as amount,count(1) as number from trade_log where mer_id = '880001'  AND trade_trans_state = 'S'  and sys_date>='20181013' and sys_date<='20181019'  GROUP BY sys_date  UNION ALL SELECT 'total' , sum(amount), sum(number)  from( SELECT sum(trans_amount) as amount,count(1) as number from trade_log where mer_id = '880001'  AND trade_trans_state = 'S'  and sys_date>='20181013' and sys_date<='20181019'))

  • 相关阅读:
    控制器View的加载过程
    iOS程序的完整启动过程(有storyboard)
    SDWebImage的使用
    iOS开发中自定义字体的方法
    3.Ubuntu 16.04.6 离线安装 docker
    2.Ubuntu 16.4.6 Server IP配置及shell访问设置
    1.VMware安装Ubuntu 16.4.6 Server
    大话设计模式读书笔记系列-5.工厂方法
    Solr4.10.4 加中文分词
    windows+tomcat8.5+solr环境配置教程
  • 原文地址:https://www.cnblogs.com/chexiedaping/p/14155368.html
Copyright © 2020-2023  润新知