insert into metadata_statistics (order_sequence, metadata_defn, total_entries, rundate, metadata_id)
select rownumber() over (order by count(1) desc), 
'PopulatedAttributesPerItem', count(1),
current timestamp, ita_item_id
from ita
where ita_company_id = 40001
and ita_next_version_id = 999999999
group by ita_item_id
;
commit;
