Please see:
https://blog.sqlauthority.com/2011/04/23/sql-server-using-decode-in-sql-server/
decode function conversion help
I m converting a script from oracle to sql - cannot come over with decode function. please help. below it is.
round(abs( decode(v.transcurr,'USD',sum(nvl(v.calc_foramount,0)), decode( c.rate_type,'I',((sum(nvl(v.calc_foramount,0)))/c.currate),'D',((sum(nvl(v.calc_foramount,0)))*c.currate) ) ) )) usd_equiv
2 answers
Sort by: Most helpful
-
-
MelissaMa-MSFT 24,201 Reputation points
2021-09-27T01:59:19.103+00:00 Hi @K P ,
Welcome to Microsoft Q&A!
decode(v.transcurr,'USD',sum(nvl(v.calc_foramount,0)), decode( c.rate_type,'I',((sum(nvl(v.calc_foramount,0)))/c.currate),'D',((sum(nvl(v.calc_foramount,0)))*c.currate) )
Please refer below to replace above part and check whether it is working.
case when v.transcurr='USD' then sum(isnull(v.calc_foramount,0)) else case when c.rate_type='I' then ((sum(isnull(v.calc_foramount,0)))/c.currate) when c.rate_type='D' then ((sum(isnull(v.calc_foramount,0)))*c.currate) end end
Best regards,
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.