Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. CREATE FUNCTION salarystatus(employee_id integer) RETURNS VARCHAR(25)
  2. DETERMINISTIC
  3. BEGIN
  4.  
  5. DECLARE isalary DECIMAL(8,2);
  6. DECLARE istatus varchar(25);
  7.  
  8. SELECT salary INTO isalary
  9. FROM employees
  10. WHERE employee_id = salarystatus.employee_id;
  11.  
  12. IF (isalary < 50000) then
  13. SET istatus = 'low income';
  14. ELSEIF (50000 <= isalary < 80000) then
  15. SET istatus = 'medium income';
  16. ELSE
  17. SET istatus = 'high income';
  18. ENDIF
  19.  
  20. RETURN istatus
  21.  
  22. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement