﻿-- [C6MartPeriodico].[PL_S170LimitiMassimi] 'F','DTARSR51M26F839O'
CREATE procedure [C6MartPeriodico].[PL_S170LimitiMassimi_20180612]
 @Rete char(1), 
 @CodiceFiscale varchar(16)
AS
BEGIN
select 'Limite massimo profilo',
       '-' as Controvalore,
	 risk.descr as rischioCreditoMassimo,
	 CR.MAX_VAR 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
INNER JOIN C6MartPERIODICO.CODIFICA_RISCHIO AS CR
ON M.PROFILO_ASS = CR.PROFILO
inner join [C6StagingPeriodico].[RISKCLASS] risk
ON m.riskclass = risk.cod
WHERE
M.RETE = @Rete AND
M.COD_FISCALE = @CodiceFiscale 
END