SQL programming language
SQL programming language
TABLE Employees (
EmployeeID INT PRIMARY KEY,
Name VARCHAR(100),
Department VARCHAR(50),
Salary DECIMAL(10, 2),
HireDate DATE
);
Sample Data:
INSERT INTO Employees (EmployeeID, Name, Department,
Salary, HireDate)
VALUES
(1, 'John Doe', 'HR', 50000.00, '2020-02-15'),
(2, 'Jane Smith', 'Finance', 75000.00, '2019-03-25'),
(3, 'Michael Brown', 'IT', 60000.00, '2021-01-10'),
(4, 'Emily Davis', 'Marketing', 55000.00, '2018-07-18'),
(5, 'David Wilson', 'IT', 80000.00, '2023-04-30'),
(6, 'Sarah Johnson', 'Finance', 95000.00, '2022-06-01');
Exercises:
Exercise 11: Simple CASE Statement for Salary Bands
Q11. Write a query to categorize employees based on their
salary into bands: Low (below 60000), Medium (60000-
79999), and High (80000 and above).
SELECT *,
CASE
WHEN salary < 60000 THEN 'Low'
WHEN salary BETWEEN 60000 AND 79999 THEN
'Medium'
ELSE 'High'
END AS salary_band
FROM
employees;