
-- use grouping() to force rollup rows to appear
-- at the end of each owner, and end of report

col owner format a20
col object_count format a30
col obj_count format 999,999

break on owner skip 1 on report skip 1

with obj as(
  select
	decode(grouping(OWNER),1,'TOTAL_OBJECTS',owner) owner
	,decode(grouping(object_type),1,'OBJECT_COUNT',object_type) object_type
	,count(*) obj_count
	,grouping(object_type) obj_gid
	,grouping(owner) own_gid
	from dba_objects
	group by rollup(owner, object_type)
)
select owner, object_type, obj_count
from obj
order by own_gid, owner, obj_gid,object_type
/
