# SQL Server total interest function for odod-first period loans

TOTALINT

Updated: 31 October 2010

Use TOTALINT to calculate the total interest on a loan or lease.
Syntax
SELECT [westclintech].[wct].[TOTALINT] (
<@Nper, float,>
,<@Pmt, float,>
,<@PV, float,>
,<@FV, float,>)
Arguments
@Nper
The number of periods in the loan or lease. @Nper is an expression of type float or of a type that can be implicitly converted to float.
@Pmt
The payment amount of the loan or lease. @Pmt is an expression of type float or of a type that can be implicitly converted to float.
@PV
The amount of the loan or lease. @PV is an expression of type float or of a type that can be implicitly converted to float.
@FV
The residual amount of the loan or lease. @FV is an expression of type float or of a type that can implicitly be converted to float.
Return Type
float
Remarks
Â·         @Nper must greater than 1
Â·         TOTALINT expects, but does not require, that @PV, @FV, and @PMT all have the same sign.
Example
Calculate the total interest on a \$3,000 loan with 15 monthly payments of \$215.
SELECT wct.TOTALINT(
15         --Number of payments
,215        --Monthly payment
,3000       --Amount of the loan
,0          --residual value
) as TOTALINT
This returns the following result.
TOTALINT
----------------------
225

(1 row(s) affected)

Calculate the total interest on a \$30,000 loan with a \$5,000 balloon payment at the end of 48 periods and a payment amount \$595.02

SELECT wct.TOTALINT(
48               --Number of payments
,595.02           --Monthly payment
,30000            --Amount of the loan
,5000             --residual value
) as TOTALINT
This produces the following result.
TOTALINT
----------------------
3560.96

(1 row(s) affected)