Database Programmability - Exercise 11.Calculating Interest
Дава ми в джъджа 66/100, ако може малко помощ.
Благодаря предварително.
DELIMITER $$
CREATE FUNCTION ufn_calculate_future_value(sum FLOAT, yearly_interest_rate FLOAT, years INT)
RETURNS DECIMAL (15,4)
BEGIN
RETURN sum*power((1+yearly_interest_rate), years);
END;
CREATE PROCEDURE usp_calculate_future_value_for_account(account_id INT, yearly_interest_rate FLOAT)
BEGIN
SELECT
a.id AS account_id,
ah.first_name,
ah.last_name,
a.balance AS current_balance,
ufn_calculate_future_value(a.balance, yearly_interest_rate, 5) AS balance_in_5_years
FROM account_holders ah
JOIN accounts a
ON a.account_holder_id = ah.id
WHERE account_id = a.id;
END;
$$