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

29 lines
1020 B
Transact-SQL

-- Stored procedure
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
--[C6MartPeriodicoImmobiliare].[PL_GetClientNegativeCurrentAccountsValue] 'S','SCLDNC71P13H224R'
CREATE procedure [C6MartPeriodicoImmobiliare].[PL_GetClientNegativeCurrentAccountsValue]
@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 @PatrimonioBF DECIMAL(15,2)
-- Insert statements for procedure here
SELECT
--@PatrimonioBF = case when isnull(SUM(CTV),0) = 0 then 0 else SUM(CTV) end
cast( case when isnull(SUM(CTV),0) = 0 then 0 else SUM(CTV) end as decimal(15,2)) as CTV
FROM
C6MartPeriodicoImmobiliare.PATRIMONIO_BF patrBF
WHERE
patrBF.Rete = @Rete
AND patrBF.Cod_Fiscale = @CodiceFiscale
AND ID_AREA = 'CC'
and CTV < 0
--Return @PatrimonioBF
END