The CASE statement can be evaluated as IF-ELSE statement.I am going to show you an example which will make the use of CASE expression more clear.
The example will match the condition and choose the category according to their salary.
Code:
select Emp_sal, case when Emp_sal < 2000 then 'Payment_category 1'
when Emp_sal < 3000 then 'Payment_category 2'
when Emp_sal < 4000 then 'Payment_category 3'
else 'Payment_category 4'
end
from employees_data;
The query using CASE statement and will allow the category according to payment given by to employee.The salary of particular employee would be checked with three conditions and if not found to all then will be send to the category 4th.
Bookmarks