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)
 what is the equivalent in sql server for this deco
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cplusplus
Aged Yak Warrior

541 Posts

Posted - 07/28/2014 :  11:39:32  Show Profile  Reply with Quote
I have the following decode used in oracle, what will be the quivalent in sql server. i tried to use with case but getting errors:

sum(decode(T_STATISTIC_INPUT.Sub_Account, 99000006, MTH_VALUE)) APD

using the following but getting error:
CASE T_STATISTIC_INPUT.Sub_Account
WHEN 99000006 THEN sum(Mth_Value)
ELSE sum(0)
END as APD

Thanks a lot for the helpful info.

MichaelJSQL
Posting Yak Master

172 Posts

Posted - 07/28/2014 :  12:08:37  Show Profile  Reply with Quote
In SQL SERVER 2008 :

you could do the following:
SUM(
CASE T_STATISTIC_INPUT.Sub_Account
WHEN 99000006 THEN MTH_VALUE
ELSE 0
END
)

In this case: if your value for the Sub_Account 99000006 it will sum the MTH_VALUE Else it will be 0
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