select 
  OPER_TIME,
  MICROPAY,
  REFUND
  from
  (
  select trunc(oper_time) oper_time, 
  class_name,
  sum(total_fee) total_fee
  from wx_pay_detail
  group by trunc(oper_time),class_name
  )
  pivot(sum(total_fee) for class_name in 
  ('MicroPay'as "MICROPAY",'Refund' as "REFUND"))
  order by oper_time

  

↑SQL,转换后列名 在FOR...IN 中AS 想要的 “名称”

相关文章: