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)
 power

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2012-10-16 : 10:33:38
Hi,
This is an excel formula:
=IF(1276<300, "NA",((34.45/100+1)^(300/1276)-1)*100)
How can I translate it to sql with power function please?

My main issue is that I can not get the power in sql to basically give the same answer as

((34.45/100+1)^(300/1276)-1)*100
The answer should be 7.21
Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2012-10-16 : 10:44:45
Use power function


select power(34.45/100+1,(300/1276)-1)*100



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2012-10-16 : 10:47:57
quote:
Originally posted by madhivanan

Use power function


select power(34.45/100+1,(300/1276)-1)*100



Madhivanan

Failing to plan is Planning to fail


This gives 7.21
=((34.45/100+1)^(300/1276)-1)*100

Your sql does not give this answer.
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-10-16 : 11:08:37
Rearrange the brackets a little bit:
(POWER((34.45/100+1),(300.0/1276))-1)*100
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-10-16 : 11:11:30
to get 7.21:
select convert(decimal(12,2),(power((34.45/100.00+1.00),(300.00/1276.00))-1.00)*100.00)


Too old to Rock'n'Roll too young to die.
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2012-10-16 : 11:28:56
Thank you
Go to Top of Page
   

- Advertisement -