insert into metadata_statistics(rundate, metadata_defn, order_sequence, total_entries, metadata_id) 
select to_date(sysdate,'YYYY-MM-DD-HH24:MI:SS'), 'ViewsPerCatalog', rownum, totals, id from 
(select count(1) totals, cvi_object_id id
from cvi
where cvi_object_type = 'CTG'
group by cvi_object_id
order by totals desc);
commit;
quit;
