﻿--select * from wh.Maledetti
CREATE procedure [C6Mart].[PL_FD187SfdrTaxESG] --'F','00545400483'
 -- Add the parameters for the stored procedure here
 @Rete char(1), 
 @CodiceFiscale varchar(16)
AS
BEGIN
declare @pref_esg varchar(2)
select @pref_esg=Preferenza_esg_cliente from C6Mart.BrsClienteESG where rete=@Rete and cod_fiscale=@CodiceFiscale
if(@pref_esg='1')
begin
select 1 as ID,
	'Prodotti sostenibili SFDR' as Descrizione,
	REPLACE(CAST(CAST(ABS(CHECKSUM(NEWID())) % 10000 AS FLOAT) / 100 AS VARCHAR(10)), '.', ',') as Peso,
	'SFDR' as Tabella
		,'N' as isNA
	union
select 2 as ID,
	'di cui in linea con le Preferenze di Sostenibilità' as Descrizione,
	REPLACE(CAST(CAST(ABS(CHECKSUM(NEWID())) % 10000 AS FLOAT) / 100 AS VARCHAR(10)), '.', ',') as Peso,
	'SFDR' as Tabella
		,'Y' as isNA
	union
select 3 as ID,
	'Prodotti non sostenibili' as Descrizione,
	REPLACE(CAST(CAST(ABS(CHECKSUM(NEWID())) % 10000 AS FLOAT) / 100 AS VARCHAR(10)), '.', ',') as Peso,
	'SFDR' as Tabella
		,'N' as isNA
	union
select 4 as ID,
	'TOTALE' as Descrizione,
	REPLACE(CAST(CAST(ABS(CHECKSUM(NEWID())) % 10000 AS FLOAT) / 100 AS VARCHAR(10)), '.', ',') as Peso,
	'SFDR' as Tabella
		,'N' as isNA
	union
select 5 as ID,
	'Prodotti ecosostenibili Taxonomy' as Descrizione,
	REPLACE(CAST(CAST(ABS(CHECKSUM(NEWID())) % 10000 AS FLOAT) / 100 AS VARCHAR(10)), '.', ',') as Peso,
	'Taxonomy' as Tabella
		,'N' as isNA
	union
select 6 as ID,
	'di cui in linea con le Preferenze di Sostenibilità' as Descrizione,
	REPLACE(CAST(CAST(ABS(CHECKSUM(NEWID())) % 10000 AS FLOAT) / 100 AS VARCHAR(10)), '.', ',') as Peso,
	'Taxonomy' as Tabella
		,'N' as isNA
	union
select 7 as ID,
	'Prodotti non ecosostenibili' as Descrizione,
	REPLACE(CAST(CAST(ABS(CHECKSUM(NEWID())) % 10000 AS FLOAT) / 100 AS VARCHAR(10)), '.', ',') as Peso,
	'Taxonomy' as Tabella
		,'N' as isNA
	union
select 8 as ID,
	'TOTALE' as Descrizione,
	REPLACE(CAST(CAST(ABS(CHECKSUM(NEWID())) % 10000 AS FLOAT) / 100 AS VARCHAR(10)), '.', ',') as Peso,
	'Taxonomy' as Tabella
		,'N' as isNA
end
END