Skip to content
Advertisement

inflation calculation in MS SQL

I have the below requirement to fulfill. How to achieve this simplistically.

There is an inflation rate table as below

I need to first get

And then get

Advertisement

Answer

I think the best way to do this on SQLserver is to use a common table expression with recursion. I’m not 100% sure because I can’t test it here, but something along these lines as the example below. Btw I assume the rates in the table are stored as fractions, so 5% is 1.05 and 10.25% is 1.1025 etc.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement