create view GetStatistics_elab
as
select s.elab as typ, rete, count(s.codicefiscale) _counter from [C6MartPeriodico].[cruscotto_contrattisei] s with (nolock)
 inner join GetStatistics_recordsToProcess t with (nolock) on t.codiceFiscale = s.codicefiscale 
group by elab, rete