0% found this document useful (0 votes)
2 views

Assignment 4

The document contains a series of SQL queries aimed at retrieving specific employee data from a database. It includes queries to find managers, clerks, employees with certain salary ranges, job roles, commission statuses, and name patterns. Each query is designed to filter employees based on various criteria such as department, job title, salary, and commission.

Uploaded by

seleniumjava63
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Assignment 4

The document contains a series of SQL queries aimed at retrieving specific employee data from a database. It includes queries to find managers, clerks, employees with certain salary ranges, job roles, commission statuses, and name patterns. Each query is designed to filter employees based on various criteria such as department, job title, salary, and commission.

Uploaded by

seleniumjava63
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment

1. Find the details of all the managers in dept. 10 and all clerks in dept 20 and
all employees who are neither managers nor clerks but whose salary is more
than or equal to 2000/-.

SELECT * FROM employees

WHERE (job = 'MANAGER' AND deptno = 10)

OR (job = 'CLERK' AND deptno = 20)

OR (job NOT IN ('MANAGER', 'CLERK') AND salary >= 2000);

2. Find the names of anyone in dept. 20 who is neither manager nor clerk.

SELECT ename FROM employees

WHERE deptno = 20 AND job NOT IN ('MANAGER', 'CLERK');

3. Find the names of employees who earn between 1200/- and 1400/-.

SELECT ename FROM employees

WHERE salary BETWEEN 1200 AND 1400;

4. Find the employees who are clerks, analysts or salesmen.

SELECT * FROM employees

WHERE job IN ('CLERK', 'ANALYST', 'SALESMAN');

5. Find the employees who are not clerks, analysts or salesmen.

SELECT * FROM employees

WHERE job NOT IN ('CLERK', 'ANALYST', 'SALESMAN');


6. Find the employees who do not receive commission.

SELECT * FROM employees

WHERE commission IS NULL OR commission = 0;

7. Find the different jobs of employees receiving commission.

SELECT DISTINCT job FROM employees

WHERE commission IS NOT NULL AND commission > 0;

8. Find the employees who do not receive commission or whose commission is


less than 100/-.

SELECT * FROM employees

WHERE commission IS NULL OR commission < 100;

9. If all the employees not receiving commission are entitled to a bonus of Rs.
250/-, show the net earnings of all the employees.

SELECT ename, salary, commission,

(salary + COALESCE(commission, 0) + CASE WHEN commission IS NULL OR


commission = 0 THEN 250 ELSE 0 END) AS net_earnings

FROM employees;

10. Find all the employees whose total earning is greater than 2000/-.

SELECT * FROM employees

WHERE (salary + COALESCE(commission, 0)) > 2000;


11. Find all the employees whose name begins or ends with 'M'.

SELECT * FROM employees

WHERE ename LIKE 'M%' OR ename LIKE '%M';

12. Find all the employees whose names contain the letter ‘M’ in any case.

SELECT * FROM employees

WHERE LOWER(ename) LIKE '%m%';

You might also like