insert into metadata_statistics (order_sequence, metadata_defn, total_entries, rundate, metadata_id)
select rownumber() over (order by count(1) desc), 
'ItemsPerCategory', count(1), 
current timestamp, icm_category_id
from icm
where icm_company_id = 40001
and icm_next_version_id = 999999999
group by icm_category_id
;
commit;
