-- Schema: C6MartPeriodico
-- Stored Procedure: PL_D_S179EmittentiConcentrazioneAlta




--[C6MartPeriodico].[PL_D_S179EmittentiConcentrazioneAlta] 'F', 'DVTMRA58B09F839W'
CREATE     procedure [C6MartPeriodico].[PL_D_S179EmittentiConcentrazioneAlta] --'W','DRNSNT51B44H090Q'
	-- Add the parameters for the stored procedure here
	@Rete char(1), 
	@CodiceFiscale varchar(16)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	declare @PROF VARCHAR(1)
	SET @PROF = (select FLGPROF from C6MartPeriodico.WSEIAN2 WHERE RETE=@Rete AND CODFIS= @CodiceFiscale)


SELECT [RETE]
      ,[COD_FISCALE]
      ,[Ordine]
      ,[Emittente]
      ,[ctv]
      ,[flagAdeguatezza]
      ,[franchigia]
      ,[percConcentrazione] * 100 as percConcentrazione
      ,case when rating='' then 'n.d.' else rating end as rating
      ,[sogliaConcentrazione] * 100 as sogliaConcentrazione
  FROM [C6MartPeriodico].[TB_S179EmittentiConcentrazioneAlta]
	where rete = @Rete
	and Cod_Fiscale = @CodiceFiscale
	and @PROF='N'
	order by emittente

END


