----------------------------------------------------------------------------------------------- -- LA FUNZIONE TORNA L'INDICATORE DI VALUTAZIONE (MIFID 2) PER IL CLIENTE SPECIFICATO -- IL DOMINIO DELL'INDICATORE PASSATO E': -- (1) - RISCHIO MERCATO -- (2) - RISCHIO CREDITO -- (3) - CONCENTRAZIONE EMITTENTI -- (4) - COMPLESSITA' -- (5) - CONCENTRAZIONE IN PRODOTTI COMPLESSI -- (6) - FREQUENZA DELLE OPERAZIONI -- (7) - LIQUIDITA'/LIQUIDABILITA' (ORIZZONTE TEMPORALI DEGLI INVESTIMENTI) -- -- select [C6Mart].[getIndicatoreValutazione] ('f','00247580970',7) CREATE FUNCTION [C6Mart].[getIndicatoreValutazione] ( @Rete char(1), @CodiceFiscale varchar(16), @indicatore smallint = 4 ) RETURNS VARCHAR(5) AS BEGIN DECLARE @retData VARCHAR(5) if @indicatore = 1 -- 1.RM (Rischio Mercato) begin select @retData = RM_ADEGUATEZZA_INDICATORE from [C6Staging].[VAR_ADEGUATEZZA_INDICATORI] where Rete = @Rete and Codice_Fiscale = @CodiceFiscale end else if @indicatore = 2 -- 2.RC (Rischio Credito) begin select @retData = RS_ADEGUATEZZA_INDICATORE from [C6Staging].[VAR_ADEGUATEZZA_INDICATORI] where Rete = @Rete and Codice_Fiscale = @CodiceFiscale end else if @indicatore = 3 -- 3.CE (Concentrazione Emittenti) begin select @retData = TH_ADEGUATEZZA_INDICATORE from [C6Staging].[VAR_ADEGUATEZZA_INDICATORI] where Rete = @Rete and Codice_Fiscale = @CodiceFiscale end else if @indicatore = 4 -- 4.CM (Complessità) begin select @retData = CM_ADEGUATEZZA_INDICATORE from [C6Staging].[VAR_ADEGUATEZZA_INDICATORI] where Rete = @Rete and Codice_Fiscale = @CodiceFiscale end else if @indicatore = 5 -- 5.CC (Concentrazione prodotti Complessi) begin select @retData = CC_ADEGUATEZZA_INDICATORE from [C6Staging].[VAR_ADEGUATEZZA_INDICATORI] where Rete = @Rete and Codice_Fiscale = @CodiceFiscale end else if @indicatore = 6 -- 6.FQ (Frequenza) begin select @retData = FQ_ADEGUATEZZA_INDICATORE from [C6Staging].[VAR_ADEGUATEZZA_INDICATORI] where Rete = @Rete and Codice_Fiscale = @CodiceFiscale end else if @indicatore = 7 -- 7.LQ (Liquidità) begin select @retData = CE_ADEGUATEZZA_INDICATORE from [C6Staging].[VAR_ADEGUATEZZA_INDICATORI] where Rete = @Rete and Codice_Fiscale = @CodiceFiscale end else if @indicatore = 8 -- 7.LQ (Liquidità) begin select @retData = CV_ADEGUATEZZA_INDICATORE from [C6Staging].[VAR_ADEGUATEZZA_INDICATORI] where Rete = @Rete and Codice_Fiscale = @CodiceFiscale end else if @indicatore = 9 -- 7.LQ (Liquidità) begin select @retData = ES_ADEGUATEZZA_INDICATORE from [C6Staging].[VAR_ADEGUATEZZA_INDICATORI] where Rete = @Rete and Codice_Fiscale = @CodiceFiscale end else set @retData = 'NN' return @retData END