talahi
asked on
Oracle 11g Pivot aggrgate sum column
Using this example below of a simple pivot query, I'm trying to also add a 4th column that sums the previous 3 columns. So the result looks like this,
CLUSTER INDEX TABLE SUM
10 468 374 852
select * from (
select object_type
from dba_objects
)
pivot
(
count(object_type)
for object_type in ('CLUSTER', 'INDEX', 'TABLE')
);
CLUSTER INDEX TABLE SUM
10 468 374 852
select * from (
select object_type
from dba_objects
)
pivot
(
count(object_type)
for object_type in ('CLUSTER', 'INDEX', 'TABLE')
);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks again. I really appreciate your help.
SELECT x.*, "'CLUSTER'" + "'INDEX'" + "'TABLE'" AS SUM
FROM (SELECT *
FROM (SELECT object_type FROM dba_objects) PIVOT (COUNT(object_type)
FOR object_type
IN ('CLUSTER', 'INDEX', 'TABLE'))) x;