-- [C6MartPeriodico].[PL_S170LimitiMassimi] 'F','DTARSR51M26F839O'
CREATE procedure [C6MartPeriodico].[PL_S170LimitiMassimi_20180702]
 @Rete char(1), 
 @CodiceFiscale varchar(16)
AS
BEGIN
select 'Limite massimo profilo',
       '-' as Controvalore,
	 isnull(risk.descr, 0) as rischioCreditoMassimo,
	 isnull(CR.MAX_VAR, 0) as  varMassimo,     
	   '-' as Diversificazione,
	   case m.experience
			when 0 then '-'
			when 1 then 'Minima'
			when 2 then 'Bassa'
			when 3 then 'Media'
			when 4 then 'Alta'
			when 5 then 'Molto alta'
			else '-'
		end as Complessita
from C6MartPERIODICO.MIFID AS M
left JOIN C6MartPERIODICO.CODIFICA_RISCHIO AS CR
ON M.PROFILO_ASS = CR.PROFILO
left join [C6StagingPeriodico].[RISKCLASS] risk
ON m.riskclass = risk.cod
WHERE
M.RETE = @Rete AND
M.COD_FISCALE = @CodiceFiscale 
END