我正在尝试将句子的结果转换为列以在 excel 中创建图表。
我有这个 sql
select
hss.instance_number INST,
to_char(snap.begin_interval_time,'dd/mm/yyyy hh24:mi:ss') as Snap_Inicial,
hss.pool,hss.name,trunc(hss.bytes/1024/1024,2) SIZE_IN_MB
FROM DBA_HIST_SGASTAT hss, dba_hist_snapshot snap
WHERE snap.instance_number = hss.instance_number
and hss.snap_id=snap.snap_id
and hss.pool='shared pool'
and hss.instance_number=1
and hss.pool is not null
and BEGIN_INTERVAL_TIME BETWEEN sysdate-5 and sysdate
and hss.name in ('KGLHD','SQLA','KGLS')
ORDER BY INST, BEGIN_INTERVAL_TIME;
我得到这个输出
INST SNAP_INICIAL POOL NAME SIZE_IN_MB
---- ------------------- ------------- -------------- ----------
1 03/05/2020 09:00:30 shared pool SQLA 150
1 03/05/2020 09:00:30 shared pool KGLS 23
1 03/05/2020 09:00:30 shared pool KGLHD 14
1 03/05/2020 09:30:32 shared pool SQLA 160
1 03/05/2020 09:30:32 shared pool KGLS 33
1 03/05/2020 09:30:32 shared pool KGLHD 10
但我想要这样的输出
INST SNAP_INICIAL POOL SQLA KGLS KGLHD
---- ------------------- ------------- ----------- -------- ---------
1 03/05/2020 09:00:30 shared pool 150 23 14
1 03/05/2020 09:30:32 shared pool 160 33 10
这可能吗?
谢谢。
你想要一个 Oracle
PIVOT
。