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
 General SQL Server Forums
 New to SQL Server Programming
 Exponent Question

Author  Topic 

apantig
Posting Yak Master

104 Posts

Posted - 2005-11-18 : 21:34:54
Hi guys,

How to use exponent in stored procedure?

Say, I need to get the exponent of

123 ^ 5

I used the ^ symbol but it gives me an error message with
XOR. I also used the EXP() but it gives me diffent value.

Please help

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-11-18 : 21:37:59
SQL Server uses the POWER() function:

SELECT POWER(123, 5)
Go to Top of Page

apantig
Posting Yak Master

104 Posts

Posted - 2005-11-18 : 21:43:45
Thank you. It works now.
Go to Top of Page

apantig
Posting Yak Master

104 Posts

Posted - 2005-11-20 : 21:58:00
Guys,

I dont think Power() would help me in my problem.

I need to get the Present Value Factor or PVFactor column in my table.

The formula is PVFactor=1 / (1 + (.10 / 12)) ^ n. Where n is an increment value starting 1 upto 50.

To get the NPV or the Net Present Value, I need to use this formula:

NPV=Amount * PVFactor

Sample Data


Amount Increment
29591.39 1
369892.40 2
29591.39 3
29591.39 4
29591.39 5
...and so on...



My question is, how to apply the EXP() or the Power() in PVFactor?



Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2005-11-20 : 22:43:40
I believe this is the correct formula for the Present Value Factor calculation:


declare @rate numeric(10,8)
declare @periods numeric(10,5)

-- Interest rate per period
select @rate = 0.005
-- Number of periods
select @periods = 360

select [PV factor] =
(1.000/@rate) - ((1.000/@rate) * power(1.000/(1.0000+@rate),@periods))



PV factor
----------------------------------------
166.791614

(1 row(s) affected)



Formula from:
http://financialrounds.blogspot.com/2005/07/math-behind-loans.html
PV factor = 1/r – (1/r) x [1/(1+r)] ^ n
= (1/0.005) – (1/0.005) x (1/1.005)^360
= 166.7916

CODO ERGO SUM
Go to Top of Page
   

- Advertisement -