Wednesday, July 23, 2014

EMI Calculation in SQL Server

Hi, Here is an example of "EMI Calculation" of Your Product
Just put the value of @Amount, @Month, @Interest and @Downpayment (If Applicable).

Now you run this query in SQL Server.
The TOTAL Details will come...

DECLARE @Amount      AS FLOAT = 13999 --Put The TOTAL Price Amount.
DECLARE @Month       AS FLOAT = 24    --Put EMI Month (Year*12).
DECLARE @Interest    AS FLOAT = 14.5  --Put Interest Rate in Percentage.
DECLARE @Downpayment AS FLOAT = 2000  --Put the DownPayment Amount if Applicable.
---------------------------------------------------------------------------------
DECLARE @Rest     AS FLOAT = (@Amount - @Downpayment)
DECLARE @Rate     AS FLOAT = (@Interest/12)/100
DECLARE @STEP1    AS FLOAT = POWER((1+@Rate),@Month)
DECLARE @STEP2    AS FLOAT = (@STEP1 - 1)
DECLARE @STEP3    AS FLOAT = (@STEP1/@STEP2)
DECLARE @EMI      AS FLOAT = @Rest * @Rate * @STEP3

SELECT 'Price Amount Rs.' AS 'EMI Details',@Amount AS 'Value'
UNION ALL
SELECT 'DownPayment Amount Rs.',@Downpayment
UNION ALL
SELECT 'EMI Months',@Month
UNION ALL
SELECT 'EMI Years',(@Month/12)
UNION ALL
SELECT 'EMI Interest Rate (%)',@Interest
UNION ALL
SELECT 'EMI Amount Rs.',ROUND(@EMI,2)
UNION ALL
SELECT 'TOTAL EMI Amount Rs.',ROUND(@EMI,2)*@Month
UNION ALL
SELECT 'TOTAL Payable Amount Rs.',(ROUND(@EMI,2)*@Month) + @Downpayment


1 comment: