PDC_REPORT_CreazioneDB/sql/storedCollaudo/C6MartPeriodico_PL_GetClientNegativeGPEligo.sql
2025-06-09 17:09:11 +02:00

32 lines
1.0 KiB
SQL

-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
--[C6MartPeriodico].[PL_GetClientNegativeGPEligo] 'S','LMNFNC40L14L219U'
CREATE procedure [C6MartPeriodico].[PL_GetClientNegativeGPEligo]
@Rete char(1),
@CodiceFiscale varchar(16),
@Codsottoprodotto varchar(10)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SELECT
--CodInterno,
--case
--when Codsottoprodotto = 'L191' then '"GP Eligo Fondi"'
--when Codsottoprodotto = 'L192' then '"GP Eligo Titoli"'
--end as Descrizione,
cast( case when isnull(SUM(CTV),0) = 0 then 0 else SUM(CTV) end as decimal(15,2)) as CTV
FROM
C6MartPeriodico.ANAG_SELF LS
WHERE
LS.rete = @Rete
AND LS.codfis = @CodiceFiscale
AND LS.CodSottoprodotto = @Codsottoprodotto
AND Ls.codinterno = 'XY'
AND ctv < 0
--group by CodInterno,codsottoprodotto
END