insert into metadata_statistics (order_sequence, metadata_defn, total_entries, rundate, metadata_id)
select rownumber() over(order by data_size desc), 
'DataSizePerItem', data_size, current timestamp, id
from (
select ita_item_id id,
sum(length(coalesce(ita_value_numeric,1))+
length(coalesce(ita_value_string,'N'))+
coalesce(length(ita_value_date),1)) as data_size
from ita 
where  ita_company_id = 40001
and ita_next_version_id = 999999999
group by ita_item_id
)as temp
;
commit;
