CREATE procedure [C6MartPeriodico].[SRV_CALCOLA_BILANCIAMENTO_GENERATOR]
AS
declare @generatorParalleli int
set @generatorParalleli = 12
declare @numeroMedioReport int
select @numeroMedioReport  = count(*) / @generatorParalleli
from c6martperiodico.vcontrattipergenerazionereport
select @numeroMedioReport
select	substring(cod_fiscale,1,1),
		count(*),
		count(*) - @numeroMedioReport as residui
from c6martperiodico.vcontrattipergenerazionereport
group by substring(cod_fiscale,1,1)
order by 1
select	substring(cod_fiscale,1,2),
		count(*)--,
		--count(*) - @numeroMedioReport as residui
from c6martperiodico.vcontrattipergenerazionereport
where substring(cod_fiscale,1,1) in ('B','C','M','P')
group by substring(cod_fiscale,1,2)
order by 1