Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. CREATE PROCEDURE usp_calculate_future_value_for_account (account_id INT, interest_rate DECIMAL(19,4))
  2.  
  3. BEGIN
  4.  
  5. DECLARE future_value DECIMAL(19,4);
  6.  
  7. DECLARE balance DECIMAL(19, 4);
  8.  
  9. SET balance := (SELECT a.balance FROM accounts AS a WHERE a.id = account_id);
  10.  
  11. SET future_value := balance * (POW((1 + interest_rate), 5));
  12.  
  13. SELECT a.id AS account_id, ah.first_name, ah.last_name, a.balance, future_value
  14.  
  15. FROM accounts AS a
  16.  
  17. INNER JOIN account_holders AS ah
  18.  
  19. ON a.account_holder_id = ah.id
  20.  
  21. AND a.id = account_id;
  22.  
  23. END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement