Login    Register

XLeratorDB/financial Documentation

IRR


IRR
 
Updated: 5 August 2010
Use IRR to calculate the internal rate of return for a series of cash flows.
Syntax
SELECT [westclintech].[wct].[IRR] (
   <@Cashflows_TableName, nvarchar(4000),>
 ,<@Cashflows_ColumnName, nvarchar(4000),>
 ,<@Cashflows_GroupedColumnName, nvarchar(4000),>
 ,<@Cashflows_GroupedColumnValue, sql_variant,>
 ,<@Guess, float,>)
Arguments
@Cashflows_TableName
the name, as text, of the table or view which contains the cash flow values to be used in the internal rate of return calculation.
@Cashflows_ColumnName
the name, as text, of the column in table which contains the cash flow value to be used in the internal rate of return calculation.
@Cashflows_GroupedColumnName
the name, as text, of the column in the table which contains the cash flows to group the results on.
 
@Cashflows_GroupedColumnValue
            the column value to do the grouping on.
 
@Guess
 
a user-supplied suggestion as to a rate of return to use as a starting point in the iteration calculations. If you do not wish to supply a guess, make this argument NULL. @Guess is an expression of type float or of a type that can be implicitly converted to float.
Return Type
float
Remarks
·         For IRR calculations, order matters, so the order in which the cash flows are returned, matters. Make sure that you either use a meaningful index or specify the order in the WHERE clause.
·         IRR and wct.NPV are related in that the IRR is solving for the value that makes the cash flows as sent to wct.NPV equal to zero.
·         IRR solves for wct.NPV equal to zero, iteratively with a maximum of 100 iterations. If IRR fails to resolve to zero within the maximum number of iterations, it will return an error.
Example
 
Create a table to store cash flow projections, by year, for a variety of projects:
CREATE TABLE [dbo].[cf1](
      [proj_no] [float] NOT NULL,
      [period] [float] NOT NULL,
      [cf_amt] [float] NOT NULL,
 CONSTRAINT [PK_cf1] PRIMARY KEY CLUSTERED
(
      [proj_no] ASC,
      [period] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
Insert the data for 3 projects into the table.
INSERT INTO cf1 VALUES(1,1,-25000)
INSERT INTO cf1 VALUES(1,2,5000)
INSERT INTO cf1 VALUES(1,3,10000)
INSERT INTO cf1 VALUES(1,4,15000)
INSERT INTO cf1 VALUES(1,5,20000)
INSERT INTO cf1 VALUES(1,6,25000)
INSERT INTO cf1 VALUES(2,1,-25000)
INSERT INTO cf1 VALUES(2,2,25000)
INSERT INTO cf1 VALUES(2,3,10000)
INSERT INTO cf1 VALUES(2,4,15000)
INSERT INTO cf1 VALUES(2,5,10000)
INSERT INTO cf1 VALUES(2,6,5000)
INSERT INTO cf1 VALUES(3,1,-25000)
INSERT INTO cf1 VALUES(3,2,5000)
INSERT INTO cf1 VALUES(3,3,25000)
INSERT INTO cf1 VALUES(3,4,10000)
INSERT INTO cf1 VALUES(3,5,20000)
INSERT INTO cf1 VALUES(3,6,15000)
 
Enter a SELECT statement to calculate the IRR for the 3 projects so as to compare the results:
select proj_no
,wct.IRR('cf1'
      ,'cf_amt'
      ,'proj_no'
      ,proj_no
      ,NULL) as IRR
from cf1
group by proj_no
 
Here is the result set
proj_no                IRR
---------------------- ----------------------
1                      0.381617314697722
2                      0.60736715747069
3                      0.46064727712306


  Comments
Add Comment
No Comments Yet


 |  View Topic History  |
Copyright 2010 WestClinTech LLC         Privacy Policy        Terms of Service