insert into metadata_statistics (order_sequence, metadata_defn, total_entries, rundate, metadata_id)
select rownumber() over (order by count(1) desc), 
'ItemsPerCatalog', count(1), 
current timestamp, itm_container_id
from itm
where itm_company_id = 40001
and itm_next_version_id = 999999999
group by itm_container_id
;
commit;
