Write a query to to calculate the bonus of each employee.
The bonus of an employee is 100% of their salary if the ID of the employee is an odd number and the employee name does not start with the character 'M'.
The bonus of an employee is 0 otherwise.
To check for Odd number we can use either of the methods:
Solutions
Using a CASE Statement:
Using a UNION Statement:
More Simplified Version:
SQL Schema
Question 2
Write a query to swap all 'f' and 'm' values (i.e., change all 'f' values to 'm' and vice versa) with a single update statement and no intermediate temporary tables.
Note that you must write a single update statement, do not write any select statement for this problem.
Question 3
Write an SQL query to delete all the duplicate emails, keeping only one unique email with the smallest id. Note that you are supposed to write a DELETE statement and not a SELECT one.
Deleting with condition, we take 2 records A and B to compare according to the criteria.