数据库多行转一行

 

 

 

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

上一篇:webSocket—消息推送


下一篇:如何mock返回数据结果