Initial Amount = $100
Interest Rate = 5%
Number of years = 3
总金额= $ 115.76
我将如何在Sql Server中计算这个?
答案 0 :(得分:1)
这是我计算总金额的方法:
DECLARE @Current_LeaseEndDate DATE = '01/31/2021' --3 Years
DECLARE @PercentIncrease FLOAT = .05
DECLARE @Principal FLOAT = 100
SELECT
YEAR(DATEADD(day, 1, CAST(@Current_LeaseEndDate AS VARCHAR(10))) + 1),
CASE WHEN YEAR(DATEADD(day, 1, CAST(@Current_LeaseEndDate AS VARCHAR(10))) + 1) >= YEAR(GETDATE())
THEN @Principal * POWER((1 + @PercentIncrease), YEAR(DATEADD(day, 1, CAST(@Current_LeaseEndDate AS VARCHAR(10))) + 1) - YEAR(GETDATE()))
END AS MEH