insert into metadata_statistics (order_sequence, metadata_defn, total_entries, rundate, metadata_id)
select rownumber() over (order by count(1) desc), 
'CategoryTreesPerCatalog', count(1) , current timestamp, caa_catalog_id
from caa
where caa_name = 'CATEGORY_TREE_ID'
and caa_next_version_id = 999999999
group by caa_catalog_id
;
commit;
