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)
 what is the equivalent in sql server for this deco

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2014-07-28 : 11:39:32
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
Constraint Violating Yak Guru

252 Posts

Posted - 2014-07-28 : 12:08:37
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
   

- Advertisement -