• 数据库多行转一行


     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'))

  • 相关阅读:
    redis数据结构-list
    reids数据结构1-string
    jedis工具类
    静态资源放行
    SpringMVC拦截器
    xinetd
    Linux-open函数
    Linux简单的文件读取
    复习ssm02
    springMVC文件上传
  • 原文地址:https://www.cnblogs.com/chexiedaping/p/14155368.html
Copyright © 2020-2023  润新知