Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Parameters with sql

$
0
0
    Hello

      i need to insert some values in parameters but how to assign values using case conditions, sum etc... i need to make separate blocks to set values? thanx

//parameters

@PE_VALOR_R nvarchar(50)

@PE_VALOR_P nvarchar(50)

@PE_DATA datetime

@PE_DATA1 datetime

SELECT 'Account' AS Funcionario,'SaldoL' AS Saldo, GETDATE()-1 AS DATA,

CASE WHEN SUM(CASE WHEN A.TIPO_MOV =1 THEN A.VALOR_MOV *-1 ELSE A.VALOR_MOV END)

>0 THEN SUM(CASE WHEN A.TIPO_MOV =1 THEN A.VALOR_MOV *-1 ELSE A.VALOR_MOV END)

ELSE 0END AS VALOR_R, CASE WHEN SUM(CASE WHEN A.TIPO_MOV =1 THEN A.VALOR_MOV *-1 ELSE A.VALOR_MOV END)

<0 THEN SUM(CASE WHEN A.TIPO_MOV =1 THEN A.VALOR_MOV *-1 ELSE A.VALOR_MOV END)

ELSE 0END AS VALOR_P

FROM Move A

LEFT JOIN Accounts B ON A.ID_Account = B.ID_Account LEFT JOIN Grupos C ON A.ID_GRUPO = C.ID_GRUPO WHERE C.DATA_GRUPO < GETDATE() GROUP BY B.DSC UNION SELECT PARTNER, DATA_VENCIMENTO AS DATA,

CASE WHEN TIPO_TITULO ='RECEBIMENTO' THEN VALOR_LIQ_TITULO ELSE 0END

AS VALOR_R,

CASE WHEN TIPO_TITULO ='PAGAMENTO' THEN VALOR_LIQ_TITULO ELSE 0END

AS VALOR_P,

CASE WHEN DATA IS NULL THEN 'N' ELSE 'S'END AS EFET FROM VW_TITLES WHERE DATA >= GETDATE()



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>