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

SQL assignment Answers-3

The document contains a list of SQL queries designed to retrieve specific employee data from a database. The queries cover various conditions such as filtering by commission, job title, department, salary, and employee names. Each query is structured to extract relevant information based on the specified criteria.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

SQL assignment Answers-3

The document contains a list of SQL queries designed to retrieve specific employee data from a database. The queries cover various conditions such as filtering by commission, job title, department, salary, and employee names. Each query is structured to extract relevant information based on the specified criteria.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Siddhesh Balghare QSpiders Wakad

QUESTIONS ON OPERATORS

1) LIST ALL THE EMPLOYEES WHOSE COMMISSION IS NULL


select *
from emp
where comm is null;
2) LIST ALL THE EMPLOYEES WHO DON’T HAVE A REPORTING MANAGER
select *
from emp
where mgr is null;
3) LIST ALL THE SALESMEN IN DEPT 30
select *
from emp
where job='SALESMAN'
and deptno=30;
4) LIST ALL THE SALESMEN IN DEPT NUMBER 30 AND HAVING SALARY
GREATER THAN 1500
select *
from emp
where job='SALESMAN'
and deptno=30
and sal>1500;
5) LIST ALL THE EMPLOYEES WHOSE NAME STARTS WITH ‘S’ OR ‘A’
select *
from emp
where ename like 'S%'
or ename like 'A%';
Siddhesh Balghare QSpiders Wakad

6) LIST ALL THE EMPLOYEES EXCEPT THOSE WHO ARE WORKING IN


DEPT 10 & 20.
select *
from emp
where deptno NOT in(10,20);
7) LIST THE EMPLOYEES WHOSE NAME DOES NOT START WITH ‘S’
select *
from emp
where ename not like 'S%';

8) LIST ALL THE EMPLOYEES WHO ARE HAVING REPORTING /


MANAGERS IN DEPT 10
select *
from emp
where mgr is not null
and deptno=10;
9) LIST ALL THE EMPLOYEES WHOSE COMMISSION IS NULL AND
WORKING AS CLERK
select *
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 *
from emp
where mgr is null
and deptno not in (10,30);
Siddhesh Balghare QSpiders Wakad

11) LIST ALL THE SALESMEN IN DEPT 30 WITH SAL MORE THAN 2450
select *
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 *
from emp
where job='ANALYST'
and deptno =20
and sal>2500;
13) LIST ALL THE EMPLOYEES WHOSE NAME STARTS WITH ‘M’
OR ‘J’
select *
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
select emp.*,sal*12 Annual_Sal
from emp
where deptno in 30;
15) LIST THE EMPLOYEES WHOSE NAME DOES NOT END WITH ‘ES’ OR
‘R’
select *
from emp
where ename not like '%ES'
and ename not like '%R';
Siddhesh Balghare QSpiders Wakad

16) LIST ALL THE EMPLOYEES WHO ARE HAVING REPORTING


MANAGERS IN DEPT 10 ALONG WITH 10% HIKE IN SALARY
select emp.*,sal*(1.1) hike_Sal
from emp
where mgr is not null
and deptno=10;

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 *
from emp
where job='SALESMAN'
and ename like '%E_'
and sal like '____';
18) DISPLAY ALL THE EMPLOYEE WHO ARE JOINED AFTER YEAR 81
select *
from emp
where hiredate>'31-dec-81';

19) DISPLAY ALL THE EMPLOYEE WHO ARE JOINED IN FEB


select *
from emp
where hiredate like '%FEB%';
Siddhesh Balghare QSpiders Wakad

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 *
from emp
where job NOT IN ('MANAGER','CLERK')
and deptno IN(10,20)
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 *
from emp
where sal not between '1000' and '2000'
and deptno in (10,20,30)
and job!='SALESMAN';
Siddhesh Balghare QSpiders Wakad

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 *
from emp
where job like '%MAN%';
24)LIST THE EMPLOYEES WHO ARE HIRED AFTER 82 AND BEFORE
87.
select *
from emp
where hiredate between '1-jan-83' and '31-dec-86';
25)WAQTD ALL THE DETAILS OF EMPLOYEES HIRED IN NOVEMBER
AND DECEMBER.
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;
Siddhesh Balghare QSpiders Wakad

27)WAQTD NAME AND DESIGNATION FOR ALL THE EMPLOYEES


HAVING REPORTING MANAGERS AND ALSO THEIR NAMES
STARTING WITH ‘S’
select ename,job
from emp
where mgr is not null
and ename like 'S%';
28)WAQTD NAME AND SALARY OF ALL THE EMPLOYEES IF THEIR
ANNUAL SALARY ENDS WITH ‘0’
select ename,sal
from emp
where sal*12 like '%0';
29)WAQTD NAME OF THE EMPLOYEE HAVING ATLEAST 2L’s
IN HIS NAME .
select ename
from emp
where ename like '%L%L%';

30)WAQTD NAME OF THE EMPLOYEES WHOS NAME STARTS WITH A


‘VOWEL’
select ename
from emp
where ename like 'A%'
or ename like 'E%'
or ename like 'I%'
or ename like 'O%'
or ename like 'U%';

You might also like