SQL Operators With Ans
SQL Operators With Ans
SQL Operators With Ans
SELECT ENAME
FROM EMP
WHERE COMM IS NULL;
SELECT ENAME
FROM EMP
WHERE MGR IS NULL;
SELECT ENAME
FROM EMP
WHERE JOB='SALESMAN' AND DEPTNO=30;
4) LIST ALL THE SALESMEN IN DEPT NUMBER 30 AND HAVING SALARY GREATER
THAN 1500
SELECT ENAME
FROM EMP
WHERE JOB='SALESMAN' AND DEPTNO=30 AND SAL>1500;
5) LIST ALL THE EMPLOYEES WHOSE NAME STARTS WITH ‘S’ OR ‘A’
SELECT ENAME
FROM EMP
WHERE ENAME LIKE 'S%' OR ENAME LIKE 'A%';
6) LIST ALL THE EMPLOYEES EXCEPT THOSE WHO ARE WORKING IN DEPT 10 & 20.
SELECT ENAME
FROM EMP
WHERE DEPTNO NOT IN(10,20);
7) LIST THE EMPLOYEES WHOSE NAME DOES NOT START WITH ‘S’
SELECT ENAME
FROM EMP
WHERE ENAME NOT LIKE 'S%';
8) LIST ALL THE EMPLOYEES WHO ARE HAVING REPORTING MANAGERS IN DEPT
10
SELECT ENAME
FROM EMP
WHERE MGR IS NOT NULL AND DEPTNO=10;
SELECT ENAME
FROM EMP
WHERE COMM IS NULL AND JOB='CLERK';
10) LIST ALL THE EMPLOYEES WHO DON’T HAVE A REPORTING MANAGER IN
DEPTNO 10 OR 30
SELECT ENAME
FROM EMP
WHERE MGR IS NULL AND DEPTNO IN(10,30);
11) LIST ALL THE SALESMEN IN DEPT 30 WITH SAL MORE THAN 2450
SELECT ENAME
FROM EMP
WHERE JOB='SALESMAN' AND DEPTNO=30 AND SAL>2450;
12) LIST ALL THE ANALYST IN DEPT NUMBER 20 AND HAVING SALARY GREATER
THAN 2500
SELECT ENAME
FROM EMP
WHERE JOB='ANALYST' AND DEPTNO=30 AND SAL>2500;
13) LIST ALL THE EMPLOYEES WHOSE NAME STARTS WITH ‘M’ OR ‘J’
SELECT ENAME
FROM EMP
WHERE ENAME LIKE 'M%' OR ENAME LIKE 'J%';
14) LIST ALL THE EMPLOYEES WITH ANNUAL SALARY EXCEPT THOSE WHO ARE
WORKING IN DEPT 30
15) LIST THE EMPLOYEES WHOSE NAME DOES NOT END WITH ‘ES’ OR ‘R’
SELECT ENAME
FROM EMP
WHERE ENAME NOT LIKE '%ES' OR ENAME NOT LIKE '%R';
16) LIST ALL THE EMPLOYEES WHO ARE HAVING REPORTING MANAGERS IN DEPT
10 ALONG WITH 10% HIKE IN SALARY
17) DISPLAY ALL THE EMPLOYEE WHO ARE ‘SALESMAN’S HAVING ‘E’ AS THE
LAST BUT ONE CHARACTER IN ENAME BUT SALARY HAVING EXACTLY 4
CHARACTER
SELECT ENAME
FROM EMP
WHERE JOB='SALESMAN' AND ENAME LIKE '%E_' AND SAL LIKE '____';
18) DISPLAY ALL THE EMPLOYEE WHO ARE JOINED AFTER YEAR 81
SELECT ENAME
FROM EMP
WHERE HIREDATE > '31-DEC-81';
SELECT ENAME
FROM EMP
WHERE HIREDATE LIKE '%FEB%';
20) LIST THE EMPLOYEES WHO ARE NOT WORKING AS MANAGERS AND CLERKS
IN DEPT 10 AND 20 WITH A SALARY IN THE RANGE OF 1000 TO 3000
SELECT ENAME
FROM EMP
WHERE JOB NOT IN('MANAGER','CLERK') AND DEPTNO IN(20,10) AND SAL
BETWEEN 1000 AND 3000;
21) LIST THE EMPLOYEES WHOSE SALARY NOT IN THE RANGE OF 1000 TO 2000
AND WORKING IN DEPT 10,20 OR 30 EXCEPT ALL SALESMEN
SELECT ENAME
FROM EMP
WHERE SAL NOT BETWEEN 1000 AND 2000 AND DEPTNO IN(10,20) OR DEPTNO=30
AND JOB !='SALESMAN';
22) LIST THE DEPARTMENT NAMES WHICH ARE HAVING LETTER ‘O’ IN THEIR
LOCATIONS AS WELL AS
THEIR DEPARTMENT NAMES
SELECT DNAME
FROM DEPT
WHERE LOC LIKE'%O%' AND DNAME LIKE'%O%';
23) DISPLAY ALL THE EMPLOYEES WHOSE JOB HAS STRING ‘MAN’ IN IT.
SELECT ENAME
FROM EMP
WHERE JOB LIKE '%MAN%';
24)LIST THE EMPLOYEES WHO ARE HIRED AFTER 82 AND BEFORE 87.
SELECT ENAME
FROM EMP
WHERE HIREDATE BETWEEN '01-JAN-83' AND '31-DEC-86';
SELECT *
FROM EMP
WHERE HIREDATE LIKE '%NOV%' OR HIREDATE LIKE '%DEC%';
26)LIST ALL THE EMPLOYEE NAMES AND COMISSION FOR THOSE EMPLOYEES
WHO EARN COMISSION MORE THAN THEIR SALARY
SELECT ENAME,COMM
FROM EMP
WHERE COMM > SAL;
SELECT ENAME,JOB
FROM EMP
WHERE MGR IS NOT NULL AND ENAME LIKE 'S%';
SELECT ENAME,SAL
FROM EMP
WHERE SAL*12 LIKE '%0';
SELECT ENAME
FROM EMP
WHERE ENAME LIKE '%L%L%';