Pass values to column to create graphs in excel
You want an Oracle PIVOT.

SELECT * FROM (
  SELECT hss.instance_number AS inst,
         snap.begin_interval_time AS snap_inicial,
         hss.pool,
         hss.name,
         TRUNC(hss.bytes / 1024 / 1024, 2) AS size_in_mb         
    FROM dba_hist_sgastat hss
    JOIN dba_hist_snapshot snap
      ON snap.instance_number = hss.instance_number
     AND snap.snap_id = hss.snap_id
   WHERE hss.pool = 'shared pool'
     AND hss.instance_number = 1
     AND hss.pool IS NOT NULL
     AND snap.begin_interval_time BETWEEN SYSDATE - 5 AND SYSDATE
     AND hss.name IN ('KGLHD', 'SQLA', 'KGLS')
)
PIVOT (
SUM(size_in_mb) FOR name IN ('KGLHD', 'SQLA', 'KGLS')
)
ORDER BY inst ASC, snap_inicial ASC;