dimanche 3 avril 2016

compounding yearly interest using tsq

I want to create a table as such using sql for compounding interest.

name    rate    principal   year1   year2
A       .5      10          15       22.5
B       .0      10          10       10.0

I am able to create a stored procedure and hardcode it for two years of interest for each name but that means that every additional year I have to add another year. Is there an elegant and efficient way for doing this using procedure(s) or just views?

Aucun commentaire:

Enregistrer un commentaire