Professional Documents
Culture Documents
SQL Notes
SQL Notes
(nomes stoxt wi y)
Ssh! pptrames having 's')
‘ys' so tnomes end with ‘6)
“pest! + erames have Consecutive '')
. Ca success)
Sse eu tc a
WHERE ENAIME Like 4g? oe Sey eu
Sh 4 —sgname he
tl vir :
¢ 7! ACE 24 charpeter is '/
~~ --- theme having sib cheaters}
‘
fs 7 joslpome having 94 letter Peon (ast
ne t's @
9
ee
°
J LIKE:
NoT Like % similar to Like operator tasted ot
|
selecting the vetords HM wit elect the records.
grtext column. name /erPression WoT LIKE "Pattern sc mokch |
= a Di
+ SELECT *
FROM €MP '
vvyYV YUU UUOUHUUUWUUUCUKOHHE
wheee ename wo LIKE ‘sk?
Questions on opewakors'-
Dd Lisk all the comply 44 whose — CommisPan fg nul:
; select ¥
, Fron EMP
WHERE comm TS NULL;
3) List out he employees Wh dork howe a REPIRTING MANAGER
1 (nee):
sevect *
; FRM ECP
' wiere Ma FS MULTE
Scanned with CamScannerR
Bist aw the SALESMAN iin DEpt 30.
serecy e
FRM CMP S*
WHERE wBs ‘salesman! AND cept plo cnt (a) 5 e
- SOR TAC CALC IMA D
Dusb at the SALESMAN 3 Deprno 30 AND HAVING e
Soleny grote” then S00 a
SELECT ee
FRM erie re
WHERE —JoR=' cALECMAN' ALO DEPTH TAN (20) And SAL >I,
Teh “Sey bepye stn) e
SList ast the employees whose Name tarts with ‘eo! os ‘A, @
SELECT x
FRM emp a
rd ,@
WHERE EWAME LIKE "3.1 oR ua? camene LIKE ‘at's 7
ae an the employees except those who ore workin
in DePE lo Ray. da e
REtecT #4 ]e
FROM Emp e
WHERE Deptno tloT XN (lo, 20)} e
ylise the ompeyers whose name does pet stort with 's!, @
SELECT # e
FRom €MP
WHERE €NAME NoT LIKE Seip? , e
Dist on the employees who are havin &
d REPARTIWG
MAMAGIERS Ty HEPT lo. <
Soe. ae ‘
FRom €rmp
WHERE MGR x5 WoT WOLL ABD DEPTNO sw (10)s '
F tsk ON the he whose — Commission ite ol ;
one) OA cLepk d
serecy & ,
FROM EMP
wheRE DeR= ‘CLERK’ AND COMM Ts NULL;
W)List aut the employe Who dont have go REPORING, MaNAGeR
mi peptwd jo oR 30.
A
Scanned with CamScannerSe gg eRe
a
- SELECT ¥
2 FROM evip
= yoneRe MGR Is Qull AUD pEPTNO TN (10,30);
7 WES on the soletmon fn dept 26 with (SELECT Min (SAL) e :
FROM EMP) ; an
DWARTD sth moximum ealory- . a
SELECT MAX(SAL) Pa a
FROM emp of
WHERE SAL< (SELECT MAx(sAU) ol
FRom emp ~
WHERE sAL¢ (SELECT MAX (SAD, al
FRom Emp oa
WHERE sALe (SELECT MAX(SAL)
aay a a
WHERE SALdSeLECT es
CAL)
FI eo a
DWAdTD name sf the ef ployee. Ren erp)
earring ard cin \
SELECT ENAME @ m Soy
FRom Emp
WRERE SAL §i(SELECT MAX (SAL)
From emp
WHERE mmBetsAL < (SELECT MAX(SAL)
FRom emp
WHERE SAL < (Select MAX Gav)
Ro »
Y wABTD EMPWO of the eroplay es ou Bi ™Ermp))y > °
Salary, 2 pnaotimcey ;
seeder ErnPN6
"FRM EMP
ne SAL Ga(SELECT max (SAD
FRom Emp
WHERE SAL < (SELECT MAX(SAY
FRom emp) 5
5) wAQTD capavtment Nome of an rece 7
g
y™ maximun soley.
aeeangnqyre
“a
oo ————————x
—
SELECT DNAMIME
~ FROM Dept
DB WHERE DEPTNomA(SELECT DEPTNO
3 FRoM EVP
7 WHERE SAL IN (SELECT MAx(SAL)
Yy FROM emp
3 WHERE SAL < (SELECT MAACSAL)
3 FROM emp
WHERE SAL<
rd (SELECT MAX (SAL)
> FROM Emp?
3 ae WHERE s AL < (ELECT mAN'SAD)
WAOTO aetotls of the FRom
em
7 empl ce. ho wor hve d SOD
3 SELECT
5 FRom emp
3 WHERE HIREDATE ay (SELECT MIN (HIREDATE)
FROM emp
= WHERE HIREDATE > (SELECT MIN(HIREDATE)
4
Py FROM EMP);
wAOTD
3 ® name of the empla ce hived before the fast
3 em plo
4 SELECT ENAME
>
= FROM Emp
cc WHERE HIREDATE XW (sELECT MAX(HIREDATE)
9 FRoM €rpP
a WHERE WIREDATE < (SELECT MAXCHIREDATE)
7 MwAOTD Loc of the employee who was ren EMP);
a ¢ ved Rivet,
geLect LOC
7 FROM DEPT
3 WHERE BEPTNO =(SELECT DEPTAS
- FRom Mp
d WHERE HIREDATE = (SELECT min (HIREDATE)
7 FRom emp);
5 VwAdtD getoils of me empleyee corning AT minimum
9 Salow.
Scanned with CamScannerSELECT # ak
FRom emp a
WHERE SAL Ai (SELECT MINGAL) e a
From emp
WHERE SAL>(SELECT Pls) e 2
Sint emp ‘ 2
WHERE SAL > (SELECT SAl
Fier emp 7 a
WHERE ¢aL> (SELECT parucsat) : 2
FRom Erp. ¥
WHERE saL> (SELECT MIN/SAL)
From Emp
WHERE SAL>
erect priw(sAt)
FRor\ Emp
WHERE SAL S—
(seLect pw(cay
FRor Empy)) 9.
warp
Duame F
oF employee ay and
SELECT pRAME maximum Sef
FROM DEPT
WHERE BEptwo au (SELECT Deptno
FRom emp
WHERE SAL “IW (SELECT MAx(sAD)
FRor @rap
WHERE SAL @ (select MArsat), :
TEngphoye® AMD MAWAGER geLaTION -
BD | Guar | mer |
(| Aes 3 |
2 | sonitH \
| a | -sames 2 |
Meas |
Cosel Lind the rye portin manager ov a il
" ey.
YWAATD name Of Alen’s mon
“eeLecy GNAME md
eRe EMP ov (select mew
wrere &t FRM emp
sei) WHERE ENAME = ‘ALLEN;
aes fai free elo FFs ero oP a a Pa
Scanned with CamScanner Dnnev Query oY subaue, enevotes o vedult oF output
1 thot wesult will be fetched a6 a input to the outer
' ery,
ry will
15 8B oking the input Prom aa ont wey w
execute Coropletely and qe oa nal vesolt.
Hence , we con ctote thet outer wey % dependent
— '
on mer | ow Sub wey:
why Where fer
case 5! Whenever hove Unknowns or Andre’ date Yin “the |
or i 5 fies:
gusition at thot Hime WS ge fer cub were
QMITH.
Ex wagTDd ename cooing SAL move thon
Scanned with CamScanneree eee aaa
> SELECT ENAME
FRot\ emp
WHERE sAL> (SELECT sal
FRom emp
WHERE ENAINE = 'sratcre!) ¢
WWAATD dome of he exrpleg
SELECT ENAME
FRM emp
WHERE SAL > (SELECT
From ep
[sn
Tei) ewam€) sAd Bn|
Vy Aven | 2000 | lo |
| |
ina B08 20 |
2
2 tone | 200) 39 |
a |
a
Jones | ase /to
KING | a0 | 20 _
es Cay more than ADAMS
sAL
WHERE EnAmet =) Apams') >
YWARTD home ond solo ef the empbyees conning less Thon
4 :
SELECT wae, SAL
FRor Emp
wweRE sAL< (select SAL
DWAHTD nome
FROM emP
,
wheRE ENAME co) RING Jy
Ane deptno of the
Ya The came pept as zones.
SELECT ENAME, DEPT NO
FRM EMP
WHERE DEPTNO = (SELECT DEpTAO
IWAQTD name
FRor
employ