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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | 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
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Blessed1978
Yak Posting Veteran

97 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
Aged Yak Warrior

USA
550 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  
 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.09 seconds. Powered By: Snitz Forums 2000