Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Amortization Report

 
   Database Help (Home) -> Programming RSS
Next:  SSAS and RADIUS authentication?  
Author Message
Ryan

External


Since: Jan 17, 2008
Posts: 6



(Msg. 1) Posted: Thu Jan 17, 2008 8:56 am
Post subject: Amortization Report
Archived from groups: microsoft>public>sqlserver>programming (more info?)

I'm creating a financial debt program using SQL 2005 as the back-end and
Access 2007 (*.accdb) as the front end for a few simple forms and reports.
One of the reports they need is an amortization schedule for project debts.
Excel has a function to perform these calculations (PPMT). Does SQL 2005
have any similar functions? It would be ideal to have the values available
in a query. If not, how about Access 2007 reports?

Thanks.

 >> Stay informed about: Amortization Report 
Back to top
Login to vote
--CELKO--

External


Since: Jan 11, 2008
Posts: 1089



(Msg. 2) Posted: Thu Jan 17, 2008 9:16 am
Post subject: Re: Amortization Report [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Here is a version of the aggregate product function in SQL so you can
do NPV and other "flow of incomes" functions in Standard SQL. The
idea is that there are three special cases - all positive numbers,one
or more zeros, and some negative numbers in the set.

Within the case where you have negative numbers, there are two sub-
cases: (1) an even number of negatives or (2) an odd number of
negatives. You then need to apply some High School algebra to
determine the sign of the final result.

SELECT CASE MIN (SIGN(nbr))
WHEN 1 THEN EXP(SUM(LN(nbr))) -- all positive numbers
WHEN 0 THEN 0.00 -- some zeroes
WHEN -1 -- some negative numbers
THEN (EXP(SUM(LN(ABS(nbr))))
* (CASE WHEN
MOD (SUM(ABS(SIGN(nbr)-1)/ 2)), 2) = 1
THEN -1.00 ELSE 1.00 END)
ELSE NULL END AS big_pi
FROM Foobar;

SELECT CASE MIN(ABS(SIGN(nbr)))
WHEN 0 THEN 0.00 -- some zeroes
ELSE -- no zeroes
EXP(SUM(LOG(ABS(NULLIF(nbr, 0)))))
* CASE WHEN MOD (CAST(SUM(ABS(SIGN(nbr)-1)/2) AS INTEGER),
2) = 1
THEN -1.00 ELSE 1.00 END
END AS big_pi

But to be honest, you would probably be better of if you built a look-
up table from calculations done with Excel or a financial package
that has more accurate computations for floating points, etc.

 >> Stay informed about: Amortization Report 
Back to top
Login to vote
Plamen Ratchev

External


Since: Jan 10, 2008
Posts: 1007



(Msg. 3) Posted: Thu Jan 17, 2008 11:44 am
Post subject: Re: Amortization Report [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

SQL Server does not provide such calculations out of the box. But the logic
for most financial functions is not so complicated and you can write your
code in T-SQL to implement those. Here is one example of PMT calculation
function I have used:

CREATE FUNCTION dbo.CalcPMT (
@principal DECIMAL(18, 2),
@payments INT,
@interest FLOAT)
RETURNS DECIMAL(18, 2)
AS
BEGIN
RETURN @principal /
(power(1 + @interest, @payments) - 1) *
(@interest * power(1 + @interest, @payments))
END

GO

SELECT dbo.CalcPMT(10000.00, 20, 0.10) AS pmt

GO

If you search Internet you will find more examples, here is another
reference:
http://www.sqljunkies.com/HowTo/FE605D6E-654A-4DBF-9FC3-976A411F7BF5.scuk

I believe the same financial function in Excel are available in the .NET
Framework libraries. You can write a CLR function to access and use those
functions. CLR may be a more efficient way to do it if performance is a
concern. Here is a reference to the .NET Library functions:
http://msdn2.microsoft.com/en-us/library/hyd90ysd(VS.80).aspx

Also, you should not have problems using the Excel functions in Access
reports. Just make sure you have checked in Tools->References the MS Excel
object library, and then you can use the formulas on the report, like
"=PPMT(...)".

HTH,

Plamen Ratchev
http://www.SQLStudio.com
 >> Stay informed about: Amortization Report 
Back to top
Login to vote
Ryan

External


Since: Jan 17, 2008
Posts: 6



(Msg. 4) Posted: Thu Jan 17, 2008 11:44 am
Post subject: Re: Amortization Report [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Plamen, thanks for your very insightful reply, most helpful Smile

"Plamen Ratchev" wrote in message

> SQL Server does not provide such calculations out of the box. But the
> logic for most financial functions is not so complicated and you can write
> your code in T-SQL to implement those. Here is one example of PMT
> calculation function I have used:
>
> CREATE FUNCTION dbo.CalcPMT (
> @principal DECIMAL(18, 2),
> @payments INT,
> @interest FLOAT)
> RETURNS DECIMAL(18, 2)
> AS
> BEGIN
> RETURN @principal /
> (power(1 + @interest, @payments) - 1) *
> (@interest * power(1 + @interest, @payments))
> END
>
> GO
>
> SELECT dbo.CalcPMT(10000.00, 20, 0.10) AS pmt
>
> GO
>
> If you search Internet you will find more examples, here is another
> reference:
> http://www.sqljunkies.com/HowTo/FE605D6E-654A-4DBF-9FC3-976A411F7BF5.scuk
>
> I believe the same financial function in Excel are available in the .NET
> Framework libraries. You can write a CLR function to access and use those
> functions. CLR may be a more efficient way to do it if performance is a
> concern. Here is a reference to the .NET Library functions:
> http://msdn2.microsoft.com/en-us/library/hyd90ysd(VS.80).aspx
>
> Also, you should not have problems using the Excel functions in Access
> reports. Just make sure you have checked in Tools->References the MS Excel
> object library, and then you can use the formulas on the report, like
> "=PPMT(...)".
>
> HTH,
>
> Plamen Ratchev
> http://www.SQLStudio.com
 >> Stay informed about: Amortization Report 
Back to top
Login to vote
Ryan

External


Since: Jan 17, 2008
Posts: 6



(Msg. 5) Posted: Thu Jan 17, 2008 11:58 am
Post subject: Re: Amortization Report [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"--CELKO--" wrote in message


>
> But to be honest, you would probably be better of if you built a look-
> up table from calculations done with Excel or a financial package
> that has more accurate computations for floating points, etc.
>
>

We currently keep the data all in a single Excel workbook with an "input"
worksheet, amortization schedules another worksheet, and finally a summary
worksheet that totals everything from the amortization sheet. The problem
is that whenever projects are added and removed, formulas in the second and
third worksheet have to be updated. The end-goal here is to create a single
place where users can input debts and then have reports that show
amortization schedules and summaries (based on all schedules). The only way
I can think of to do this is to do all calculations on the SQL side that way
I can simply display everything in an Access report (and have the input form
in that same Access file). I may end up developing a custom application, I
was trying to avoid that in the interest of saving time (and to keep the
end-product editable by the end-users).

Thanks and all advice is appreciated.
 >> Stay informed about: Amortization Report 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
How to modify a report in Crystal Report 7 - I am a Web developer. I am new to VB 6.0 and Crystal Report. I have joined an organisation where there is an application running(developed in VB6 and crystal report 7). I have to modify one report. In two columns I have to make minor changes i.e put &gt...

Login failed for user 'NT AUTHORITYSYSTEM'. [CLIENT: 192.1.. - It's been suggested that I post here rather than in the windows.server.sbs WIN2003SBS Premium R2 Help! This error is appearing every one minute when SQL Server and SQL Server Agent are running (but not when not): Event Type: Failure Audit Event..

monthly report - how to group the data by monthly? thanks...

Help with report/pivot - I am doing a report that shows 1 column per count of transactions for each of 2 different status, + the overall total, and 1 row per product type, of which there are 4. So I need four rows and three columns of counts. The code is not working because it....

Need help on how to write this report. - Hi, Does anyone knows where can I get a script to generate backup and restore information like the one show below. I need to do this quick for my boss and can't think of a way to write this fast. Any helps would greatly appreciate. DatabaseName ...
   Database Help (Home) -> Programming All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]