Date:19102121: Ex - No: 3
Date:19102121: Ex - No: 3
NO: 3
DATE:19102121 NESTED QUERIEs
AIM
To execute and verify nested queries in RDBMS
PROCEDURE
A. NESTED QUERIES
Types
1. Independent Nested Queries:
n Tndependenk nebh Qupy, qLEuy eseution Statts erom
sets
Set Comparison: To comparc
,Some Gome mubk maeh OLk One 1Molu tn the Sub4i Lph
dnd mubt be piceeded by Compuuson OPetako
all
mubk na kch cul dows in the Sub-quet4
exists
Not exists
T 5 ubed lo Febt o fue xebtence ony 1ecod
w t u cheek Hhe Sub-qpuo-uy r Hhe i6w
e t tence and ( heue ate no 4ow, then c o
r Hue alwo
unique
enbuwueb all hue Uatupb ate drtfoment
EMPNO NUMBER(6)
ENAME VARCHAR2(20)
JOB VARCHAR2(10)
DEPTNO NUMBER(3)
SALARY NUMBER(7.2)
Create a table called DEPT with the
following structure.
Name Type
DEPTNO NUMBER(2)
DNAME VARCHAR2(10)
LOC VARCHAR2(10)
Mathi AP 10000
ASP
Arjun 12000
Gugan ASP 20000
4 Karthik AP 15000
DEPTN0 DNAME LOC
-----
Nested Queries:
Q1: Display all employee names and salary whose salary is greater than
salary of the company and job title starts with M'. AG
minimum
Query: : Seleck
name,Sclay om emp wnuee Sculay> (Selere min(Sala,
uememe Sand iob uee as
Output:
Q2: Issue a
Query: to find all the employees who work in the same job as Arjun.
Query:: Seleet nomn emp wherue aob uee CSelett job uo m emp
whee emme = ayun'),
Output:
03: Issue a
Query: to display information about employees who earn more than any
employee in dept 1.
Query: SeleeE upn emplbyee where Salt > Some CSelece Salnu
Pvern ene whwe depeno=1)
Output:
Q4: Union
Query
SwrE wm dept wion Sptett
em dept-1
Output:
Query
SeLect sm depe nional Selere n dept
Output:
Q4: Intersect
Query
Select en depe tnoubert SeLEEE Bem depe
Output:
Q4: minus
Query
Seerte ern dlept Minus Seleel Bhem depE1
Output:
JcbASP
Output:
ry
bm emp Otu 6y dept no debC, enp.no abe
Output:
Output:
MARK ALLOCATION
CONTINUOUS INTERNAL ASSESSMENTT
Conduct of Experiment (20)
Record & Result (15)
Viva (15)
Total (50)
9gan 20 000
20006
9Lugon
3. Empno Ename Joo Deptnd Sculby
cusP 2 2000D
Kocuhi.k ap
CHun asP 2 2 000
actountng newyouR
eSenuch dalunb
mauPeing Chenntu
openakin19 boston
attounkng
eenuth dnlleus
OLttounkn9 NEupyotR
ebeahth douad
meURettnq chenneu
Dept no Drame LoCeutien
touunt ing reuW yoR
ebeahcn drun
Count (Empno
Deptna Ennme
ayun
gunn
mauth
KathicR
lo. DeptNo