?
行转列,使用case when then
?
select date, sum(case c.type when 'try-pay' then c.sum else 0 end ) as 'try-pay', sum(case c.type when 'pay-real' then c.sum else 0 end )as 'pay-real', sum(case c.type when 'pay-success' then c.sum else 0 end )as 'pay-success', sum(case c.type when 'pay-failure' then c.sum else 0 end )as 'pay-failure', sum(case c.type when 'notify-input' then c.sum else 0 end )as 'notify-input', sum(case c.type when 'normal-query' then c.sum else 0 end )as 'normal-query' from (SELECT sum(f_count) as sum ,f_type as type ,f_date as date FROM t_log_analyse group by f_type,f_date order by f_date desc) as c group by date
?
?