table contains a record of name
salary
like this
I want a deduction of 5000 from every employee. If the salary < 0
then i need to display "insuffiecient for deduction" if salary > 0
then " can be deducted"
This is the images of the table.
table contains a record of name
salary
like this
I want a deduction of 5000 from every employee. If the salary < 0
then i need to display "insuffiecient for deduction" if salary > 0
then " can be deducted"
This is the images of the table.
Try the query below:
SELECT `name`, `sal`, IF((`sal`-5000)<0,'insufficient for deduction','can be deducted') AS `status` FROM `employee`;
I only use the name
and sal
field since this two fields are only needed to solve your problem. The formula used was:
(`sal`-5000)<0
which means that the salary of certain employee will be deducted by 5000 and then immediately compare if it's negative or positive. If the result is negative it means that it's 'insufficient for deduction' else 'can be deducted'.
Try this solution, i have added case when, which will help you.
Note: you can add the field as per your requirement