insert into metadata_statistics (order_sequence, metadata_defn, total_entries, rundate, metadata_id)
select rownumber() over (order by count(1) desc), 
'SpecsPerItems', count(1), current timestamp, items from
(
select ita_item_id as items, nod_spec_id as specs
from ita, nod
where ita_company_id = 40001
and ita_next_version_id = 999999999
and ita_node_id = nod_id
and nod_company_id = ita_company_id
and nod_next_version_id = ita_next_version_id
group by ita_item_id, nod_spec_id
) as temp
group by items
;
commit;
