ASSIGNMENT ON SPECIAL OPERATORS:
1) List all the employees whose commission is NULL.
Ans: SELECT * FROM EMP WHERE COMM IS NULL;
2) List all the employees who don't have a reporting manager.
Ans: SELECT * FROM EMP WHERE MGR IS NULL;
3) List all the salesmen in department 30.
Ans: SELECT * FROM EMP WHERE JOB = 'SALESMAN' AND DEPTNO = 30;
4) List all the salesmen in department 30 and having a salary greater than 1500.
Ans: SELECT * FROM EMP WHERE JOB = 'SALESMAN' AND DEPTNO = 30 AND SAL >
1500;
5) List all the employees whose name starts with 'S' or 'A'.
Ans: SELECT * FROM EMP WHERE ENAME LIKE 'S%' OR ENAME LIKE 'A%';
6) List all the employees except those working in department 10 and 20.
Ans: SELECT * FROM EMP WHERE DEPTNO NOT IN (10,20);
7) List the employees whose name does not start with 'S'.
Ans: SELECT * FROM EMP WHERE ENAME NOT LIKE 'S%';
8) List all the employees who have reporting managers in department 10.
Ans: SELECT * FROM EMP WHERE MGR IN (SELECT EMPNO FROM EMP WHERE
DEPTNO = 10);
9) List all the employees whose commission is NULL and are working as clerks.
Ans: SELECT * FROM EMP WHERE COMM IS NULL AND JOB = 'CLERK';
10) List all the employees who don't have a reporting manager and are working in
department 10 or 30.
Ans: SELECT * FROM EMP WHERE MGR IS NULL AND (DEPTNO = 10 OR DEPTNO =
30);
11) List all the salesmen in department 30 with a salary greater than 2450.
Ans: SELECT * FROM EMP WHERE JOB = 'SALESMAN' AND DEPTNO = 30 AND SAL >
2450;
12) List all the analysts in department 20 and having a salary greater than 2500.
Ans: SELECT * FROM EMP WHERE JOB = 'ANALYST' AND DEPTNO = 20 AND SAL >
2500;
13) List all the employees whose name starts with 'M' or 'J'.
Ans: SELECT * FROM EMP WHERE ENAME LIKE 'M%' OR ENAME LIKE 'J%';
14) List all the employees with an annual salary except those working in
department 30.
Ans: SELECT ENAME, SAL * 12 AS ANNUAL_SALARY FROM EMP WHERE DEPTNO
NOT IN (30);
15) List all the employees whose name ends with 'ES' or 'R'.
Ans: SELECT * FROM EMP WHERE ENAME LIKE '%ES' OR ENAME LIKE '%R';
16) List all the employees who have reporting managers in department 10, and are
having a 10% hike in salary.
Ans: SELECT * FROM EMP WHERE MGR IN (SELECT EMPNO FROM EMP WHERE
DEPTNO = 10) AND SAL * 1.10 = SAL;
17) Display all the employees who are salesmen and have 'E' as the second-to-last
character in their name, with a salary having exactly 4 digits.
Ans: SELECT * FROM EMP WHERE JOB = 'SALESMAN' AND ENAME LIKE '%E_' AND
LENGTH(SAL) = 4;
18) Display all the employees who joined after the year 1981.
Ans: SELECT * FROM EMP WHERE HIREDATE > '31-DEC-81';
19) Display all the employees who joined in February.
Ans: SELECT * FROM EMP WHERE TO_CHAR(HIREDATE, 'MM') = '02';
20) List the employees who are not working as managers or clerks in department 10
and 20, and have a salary in the range of 1000 to 3000.
Ans: SELECT * FROM EMP WHERE JOB NOT IN ('MANAGER', 'CLERK') AND DEPTNO
IN (10, 20) AND SAL BETWEEN 1000 AND 3000;