SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 PLSQL TO TSQL
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Blessed1978
Yak Posting Veteran

73 Posts

Posted - 03/06/2014 :  11:54:13  Show Profile  Reply with Quote
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
Constraint Violating Yak Guru

USA
421 Posts

Posted - 03/07/2014 :  10:31:24  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000