insert into metadata_statistics (order_sequence, metadata_defn, total_entries, rundate, metadata_id)
select rownumber() over (order by count(1) desc),
'CategoriesPerDepth', count(1), current timestamp, chi_parent_id
from chi
where chi_company_id = 40001
and chi_next_version_id = 999999999
group by chi_parent_id
;
commit;
