Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE FUNCTION ufn_calculate_future_value (sum DECIMAL(38,18),interest DECIMAL(38,18), years INT)
- RETURNS DECIMAL(38,18)
- BEGIN
- DECLARE result DECIMAL (38,18);
- SET result := sum * pow(1 + interest,years);
- RETURN result;
- END;
- CREATE PROCEDURE usp_calculate_future_value_for_account (account_id INT, interest_rate DECIMAL(13,4))
- BEGIN
- SELECT account_id,
- ah.first_name,
- ah.last_name,
- a.balance AS 'current_balance',
- round(ufn_calculate_future_value(a.balance,interest_rate,5),4)
- AS 'balance_in_5_years'
- FROM account_holders ah
- JOIN accounts a ON ah.id = a.account_holder_id
- WHERE a.id=account_id;
- END;
Advertisement
Add Comment
Please, Sign In to add comment