Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 PLSQL TO TSQL

Author  Topic 

Blessed1978
Yak Posting Veteran

97 Posts

Posted - 2014-03-06 : 11:54:13
convert the below plsql to TSQL

DECODE(BAL.CURRENCY_CODE,'STAT',0,NVL(BAL.PROJECT_TO_DATE_DR,0)-NVL(BAL.PROJECT_TO_DATE_CR,0)+(NVL(BAL.PERIOD_NET_DR,0)-NVL(BAL.PERIOD_NET_CR,0))) CLOSING_BAL_AMT


I am using this code but the numbers are off

CASE WHEN BAL.CURRENCY_CODE = 'STAT' THEN 0
ELSE (ISNULL(BAL.PROJECT_TO_DATE_DR,0) - ISNULL(BAL.PROJECT_TO_DATE_CR,0) + (ISNULL(BAL.PERIOD_NET_DR,0) - ISNULL(BAL.PERIOD_NET_CR,0)) )

please advise

ScottPletcher
Aged Yak Warrior

550 Posts

Posted - 2014-03-07 : 10:31:24
The only difference I can see is that you've added some parentheses. And given that you're doing only + and -, not sure why that's causing an issue.


CASE WHEN BAL.CURRENCY_CODE = 'STAT' THEN 0
ELSE ISNULL(BAL.PROJECT_TO_DATE_DR,0) -
ISNULL(BAL.PROJECT_TO_DATE_CR,0) +
ISNULL(BAL.PERIOD_NET_DR,0) -
ISNULL(BAL.PERIOD_NET_CR,0)
END AS CLOSING_BAL_AMT
Go to Top of Page
   

- Advertisement -