Oracle根据【日期】组,其他条件根据PIVOT行转列。使每个日期条件关联的其他数据只有一行。
时间:2017-11-23 16:33:28
收藏:0
阅读:1185
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 想要的 “名称”
评论(0)