Advertisement
elena1234

Salary Level Function ( T-SQL )

Jan 10th, 2022 (edited)
4,272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.38 KB | None | 0 0
  1. CREATE FUNCTION ufn_GetSalaryLevel (@salary DECIMAL(18,4))
  2. RETURNS varchar(10) AS
  3. BEGIN
  4.   DECLARE @SalaryLevel VARCHAR(10)
  5.   SET @SalaryLevel =
  6.     CASE
  7.     WHEN @salary < 30000 THEN 'Low'
  8.     WHEN @salary > 50000 THEN 'High'
  9.     ELSE 'Average'
  10.      END
  11.     RETURN @SalaryLevel
  12. END;
  13.  
  14. SELECT Salary, dbo.ufn_GetSalaryLevel(Salary) AS [Salary Level]
  15. FROM Employees
  16. GO
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement