Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE FUNCTION `ufn_calculate_future_value`(`sum` DECIMAL(10, 4),
- yearly_interest_rate DOUBLE,
- number_of_years INT)
- RETURNS DECIMAL(10, 4)
- DETERMINISTIC
- BEGIN
- RETURN `sum` * (POW((1 + yearly_interest_rate), number_of_years));
- END;
- CREATE PROCEDURE `usp_calculate_future_value_for_account`(account_id INT, interest_rate DOUBLE(19,4))
- BEGIN
- SELECT a.id, ah.first_name, ah.last_name, a.balance,
- `ufn_calculate_future_value`(a.balance, interest_rate, 5)
- FROM accounts AS a
- JOIN account_holders AS ah
- ON a.account_holder_id = ah.id
- WHERE a.id = account_id;
- END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement