zoukankan      html  css  js  c++  java
  • 数据库多行转一行

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

  • 相关阅读:
    论文阅读:Deep Attentive Tracking via Reciprocative Learning
    Paper Read: Convolutional Image Captioning
    论文笔记: Mutual Learning to Adapt for Joint Human Parsing and Pose Estimation
    Macro-Micro Adversarial Network for Human Parsing
    论文笔记:Mask R-CNN
    算法——贝叶斯
    算法——递推算法
    跟我一起云计算(5)——Shards
    跟我一起云计算(4)——lucene
    跟我一起云计算(3)——hbase
  • 原文地址:https://www.cnblogs.com/chexiedaping/p/14155368.html
Copyright © 2011-2022 走看看