Hi experts, I have 1 table contains 4 columns of price, durations, interest and balance. I can get the duration month from 1 to 12months. However, I am having problem with the interest calculation within 12 months. output is like:
Price duration(month) interest balance
2000 1 200 2200
2200 2 220 2420

and so on until 12months...the duration can display 12months but the price, interest and balance are shown NULL. Any experts please guide me on this, thank you very much.

set duration = (SELECT duration FROM tblprice WHERE id = 1);
set a = (duration * 12);

set interest = (SELECT costs*(duration*12)/1830 FROM tblprice WHERE id = 1);
set i = (interest);

WHILE (v_duration <= a) DO
INSERT INTO tmp(duration)
values (v_duration);
SET v_duration = v_duration +1;

 WHILE (v_interest<= i) DO
 INSERT INTO tmp(interest)
set v_interest = v_interest;

SELECT * from tmp;