Download as pdf
Download as pdf
You are on page 1of 24
| isi. give output ‘will be givea as on Snput tov | : “Types oF era ee tt ee 1 hfe Aaonmele apa TG i fhe jnnex quay us] execute fiesi pew outen Quen oubec quel w0i\)_exectut anol gives wa +ne final output, i alae 1590" Wie ewe cure 4.00 typed of el hey ane iv follows or aM ee | y_Sin [pe Rone Sabie Bide hi a fouy Mult - Row Subquasy Scanned with CamScanner vives _anly one at ey wil) execute 491s z | i o. a ue ee be given os 1) ot output one some output coill b a aa | outer quey “foe outer queuy sill execu je tne ou. queiy. as) fs ak a land gies fined outputs 2 ————— ___+ ee jest anol ven mupiple ovdtput— a as jes akcinse Aare gee ee Sinput — ol tne Outer Be outer feat executes or ol Fes ea he | ae We [Teter ane finest A. Te Scanned with CamScanner pare 1.10, 21 ace no: —! Que: ||wthy clo we use Subgueny ? —__-— che date 4 ‘present in one table and condition jaf BY _ Ihe date 34 present jn tie table but it is unknown. Re. paee sa i is_paesent Riot qrorne cn Sac iemaen ae Beers EDatames present Sn the table but it 2s unknow + ||Wagto tne name f Salauy of the employee is aia qrsetes stnan sites satan, —— ason 4% who earns _ __@ fren emp Nes @_whwie _enome in _'Soo) TH BL, _ *_||WAQTD ename if a } before FORD was hie e ; | eae a oe ties e a 2 || select ename, nivecate _ y } from ean a Be ae le ALS i e@ | wnue iveclate (| Select hizead pure. 0 i | | From em Pi = ei new. | t a Beas hima Me wnuie ename |o'foRo )5 | Scanned with CamScanner pune ol a CCR CEC a CoE EY eV AA | \ Som | | \ jaar ——H = eovud | | Ll Reason 22 Be 5S oad ee Daja is present in_one able f Condiion 4s present fh anothus table. eS Select Loc ‘inp piste voheue clepino Int _( Select deptno toc_o} -tne_ erployees— who works. snot op Allen's . ——— Scanned with CamScanner meee Ss: Scanned with CamScanner ~~) 4 l| 4 ,10, 21 ~: ie es ——— ~—__- eee J | Seleet_ename, sat y Pom emp Jee oncensate a (Selec sal Ld ae ari Recovers pIseisbnis fener zs ante oh whexe ename IN ‘SmITH’) ane| Ea & (Select Sat J» Pesce oa Name emetienie: | cet iy ies whee ename eee i pa) es i In BLAKE’) 5 5) { ‘ f a waatl +he name ancl niredote of -tne employees ode | axte_hiaedl_betore smith and Hired atter placke . ____ Sa a -- 7 op aes Select Te ete ei pur 4 ree bs 2 = ||Pzorn_empe ee — 3 pure issectate < (Selicet niredate att i Farorn emp a evel ename_ int ‘omytn!) ane ninectate > ier Ati i __( select rineolate ‘ | poateal? whee ename __im ‘ptage’) 5 v9 1 | nployees who ave eOerTki works _ > Alen! ane) — Scanned with CamScanner pene hor |_foum emp _ | | where ename In | atten’) ae apes Select Oname, Loc oare 4 10,21 Jin Smae | on _+ne_ Same bet: WAGTD Dname ancl LOC of _4ne ob as tat op SCOT __when fo yn eve ge Munrceiees “depend form 2 ee whee Tops PACE: Be _phewe Be int Cgelect clertno From slept _ Piogto _taicau1o’) 5 t_and loyecs Who O78 ~- xc] wos hireol. __@ IN, [select yon _faoro emp __— ell neywe ename _ | whee nar el whee int gcorr) and | nine’ scott) eal nivectate tn _ ename race te: S aes | : WAQTD the name and hisectate cf ne employees wo _ tu. ihe f aue working $n -+ne Biches Ce Depart meat. ancl earns Sala lesser than ne comm cP BLAKE and qaeaten Lnan Seley cF Borel iF e g Lt lselect ename, hireclate _ : 2 e i (eat CNM la rt wt Select Dept NO wh eu @ pt NO} t form Dep here Dname peuecmmes cast» |) mre 110, 21 Jo, 2) empre 000% é ic ei ©) @) = 2 Bea “9 L as: PN € wi RN Zh s a ~ = SaaD ADI _NISHA__RAmiT __ ga Meee e P9800 eee 000 OOS 0006 2 Mieg|hiei a | | Le soe miners ae a * fhe approach 40 _finel Some employees manager ie ean) ee ent — _. |waatd tne name op _smTHs manager “ z ca ate ee Seleck ename Ba a __|| Poem emp _ ie af —_—— were _empno_|n_ pica “rome | a | fea emp —_—_—* 2 | _woinere ename IN | smi tH 1.) eet ‘< a « e e € e a bi ies e ee te, ' rye Same iiere coame |" intr) > 4 - ae é Scanned with CamScanner ‘6 ag Monernplayces,—>7.F'" «manag er—> eropno ees —_ Pace no; 1 4 = = weeny | How +0. Hind tne employees _wino_ave wor Someone oF reporting +0 Someone. “4 ence eel + |wAQTd tne name of employees veperting +o King or undey_King.. a Select ename _ Prom _emp P z whee Mg In (select cag ee ci from emp whee ename IN t KIN G7!) 5 hs _+ lweatn ne name ef smitn’s manager's _moanad or. 2 J | Select ename i! e Poon _ennp “wneie eropno_in Setect_mg% Peongme em (ee Her _ were _empne_|n (select mgr __peom emp uphere _ename Miler ra) 5 er “(select _Deptna — pec ep | Scanned with CamScanner one 5/021 a2 race Ne: uhh where _empno Io _{ Select mg% 0 Prom emp = es 3 _ whee _empno In _( Select max cl vee 4 Foor emp whee ename In een rrite eeS orhs)) Ya fu WAQTO the name 4 \ob of tne empl OM Ce Smug whe ae | eesti) Ga eiake’s manage? leedect Aname, LOC Be plait [Porno Dep} —— F areal ole iis eect were) ae nie eeee ae Paom ¢ Scanned with CamScanner id tbdaa DAReD Ih we_trnpro in ( elect mgr | i _____ Pau emp ename So Drom emp where emp no 30 (select mar Poe emp _winere_enarr in 'oLA ~)J— a Js eres Pines ee ce i [wWAATD the Details of tne employees wd € ssalany Naa fn tne Same Department > | Ltnree olf gits and werk: — ne]_cloes not weport 0 _ jas that of ‘scorr’ monages Ke | bloke s manages. ss ri at ee eemeripieey = ane} _Dipiro” corr!) and: Mb1R iNOT ID (select emp poten Peon emp _— Be: Scanned with CamScanner MN Se 8 8 eo et oh ol Db obalelel od oda ebLEELEEE . ith CamScanner ee oe Hlocaes by clause 41 260! » Ascenclé clescenclir Ou et ete ay ae eo aw, a an —_— | - i syntax % | ey ee a cas) a : mession [cas] ate ined) _colname | ex pre | fern retrace Tonewe << Filter conalitfien > _ jgreur by cel Lexpression _ ae wl Busca, pals 1c i 5 Vnavin “< cond” on rare | cond” on grup Cy co) ) exp | > {Orden "3 cojnarne _[expressieo_ case] Hi ies cy mee i 5 - = ; 3 Hapuwre oP executor r - i aa ge Neto) yee te Kee ra fable Prom Database f put t+ uncle MI ms emeculcenin smelt aioe # Po ROL - Bis ~ Row - Row = by = Row a SE eas paneer O eS + cg Inovding pe (peop - by = Boop __g: |) Select _=— Bt _tyreup oy = Group ae a ‘Duder by rep = by = Yroup ll Scanned with CamScanner PAGE No: inthe seer ae Orem ee em LG ah ae eo | Oreotere i Asal Asc 5, eee |; _——*8 re ri ae ere Select Sat + |WaaTD +e Salany tn descending Orcler Select val | fom aap ee Oude by Sat olesc 5 au i ere « |wa@ro +ne Name op employees 1° ascencling || Ooder _ eee ana a em eal || select _ename | Peon emp 2 ‘| Ostler a! ename 5 es In _alescensting i [weet * he same op_enpinys | Oncler. _ ta ss em eel sefect ena - = | Foor &Op [Onder bY ename | Peper eeepere clesc 5 Scanned with CamScanner , .) | re @ 10, 2) ae qe — = ———— PAGE No cis aE gore ee bares i a ——|[-f Seveo Te 8 i a ~ 6 oe el owe ffaize cetuemns are Wie se theta jive _puesert ee table beet , by_efe lover ft will not be cltsplayed.” “frie cure bdo s5)pes > of (pape Column ney aie cy follows 4 ws RIUM Sa 2 Tesla > 3H LW) ROWNUM . | Select ename , wowiel, wownu nn 2. x | Poon an ae ae —_—— o [select Dname, rovhd, 2oOnum iz ae Pour Dept Bek a ix ||Setect emp-x., aowid , saw our) ae OR, [prem eonp j ae saw ay i a eed $, a 18 chanacier aclelwess of cee wecozd, jt 4s uni que_f. Deoois ar, Uaeeean Le Ad blu Lit a mod Nutty oh a ; 6 ut a table 2 not having any Key attsibute jo make a a , roauy Key, 2 vey. ule can make 20.0% < auy Hey. We car ; ‘te MECOD oe nen Pie _9DW. when “we inset tne net? 2s wil) be grosastel mi Scanned with CamScanner ve ok = Slee mei ~ me oe aoe see pit * ts pms ie me ) 1 Se Osis a4 @ Sadat Wunber 0} given 7) Pe omoles but UF is nek Comstemt Gis ed, BM owe Nua yes Ar Migr ic ED, 4) | cant make ft as _putmony key? f ) le cannot make sou au es because gad, een iow consiany a SD, 5) || Row-num oi) be oS ami tne execution D, a of the quent. en a P, 6) re efoult value of ronum a 4 ae _ 4) | Winy do we we — Row -numn Z i eee To get tne NI? max oF _ io rin ed ee waAgro ane a*t max saleny.. | setect ec on | Booro emf vonwie Sade Scanned with CamScanner i Setect max (set) NON IUMRco stern ae Poom emp Bea _ || wonee Sat _< (Select max (st) Ay —— fee 0 2 Je J i ve ik i 2 Bi it @- Per ea re S74 maximum Satay pee pee a Pp ae ctect maxtsat) i i Se We rorn ern pil TE eteae 50a 4 Hee Ee er a aa i Say get Not In (Select max Wat) _ ARS i ae ne a : fro canis t 3 i egy chia ls where set Not In ( select a CS ese nese ee __max(sst) t I—_|}— zs _ fro emp) Beil ° i 5 tae ae ear R nN e ee eee i Faia t 4 __||setect max Gat) __— L____|[peum em prone psa 2 are Lz | crore sat < [select max (5-0 is Es {| i lane from erp * LF I fa hea ipnere sat < [Seleck max teat) | : | ope free emp ) 5 iiaanode 4st minimum salary Scanned with CamScanner || owre 6,10, 2} + waatn the 224 minimu Select mio (sat) cvigpanern py aa Poor emp. [select min iat) _ pee whee Sok not in ! Setect min (sat) i Bs Hwee i: woneté soul _ aE geteck rnin (824) nok 19 (ee capa (Setect Poin (eat) a fren cco) Pena __where era > {select Erving (sat) P vu ] Jew emp ))5 weit | UU Uw?) | | |i i Step No 4% Wace nea. L we exp yg! [un Ration teetau cence colur of “Oniclox -by eee * Taiminate tne “clupttcate | Salacces bai aa Distinct if a elect nistinct sat © gel tne N™ max saany we need to sae tne Salaries in descending Order select clisHinet sat _ y Sal i 5000 oe — Fee ae 3000 : Me lmeclescay, | _@) oud by 2 iat ae 7 re armen 2390 ens Some output 1600 Ike, ___— 1500 ASMP esto eae | 1300) tne Next tevle .] 1260 ee noo ae qo &£00 | 6 0,2) 1 llexpecteof Output *_ [pnt | 5000 = 3000 ieee clistinct sat, 2470 sownum 2800 ies emp | I600_ ci Ou. cx sat desc 5 _ 1800 a i 100 iE __ 1280 ah mk 100 ee || prada oP 400 I is 500 | Actual Oe rues we ane not etting tne ex pect eof west axpecteet reste |SO_ te get > |aownum p20 we have oa eee wreete +e | jalewing— sd I} equens| J SPEPETEVE? Scanned with CamScanner Select Sal, qownun _ pias Sie Foun (Select clisHinct Sat abe: Poonuern Pl z te DP oxen by oleh) SB aa wes es i ee 4 3 To ioueeraeraee 48t max _ ae we have to » Following au oUTe ero FRAN AT: Bee “Select sal , oon) a __wuite +h __ Fao (Select folistiine bunsat yet _ Foun em Pasay RAEN Se Osidler by Sak plese) _ whee _s0tonum = will only work fox 20wnum = a! e of wownum= 1 Nore 3 the above quen because tne cletault valu we cannot find Ni? maximum Selaty by “using above _quetyf = — © _ sctect sat cowoum ea Smo ___ @ beer (© select ctéstinet sat Se Pg oe ee amy set " aleze) ee ae Scanned with CamScanner Scanned with CamScanner a mae Ta = PAoe ee ee Se 7 ~[songrn ne _Drame_§ LOC of tne employee wr ers » ) |) 10 maximurng setaxy p—— oe aoe ze ___||Setect Dname Le _ eae | peo 2D ieee a ei [fon ere Depino In| (Setect Deptno oe I ze — Pour emy® ________ = jase SS __ where Sat 19 (select § Pour [select sot, rownum 4 $7N0 pepvanpeetes io eee Wee Crawl setcek a pistfot Sots ae fi enh! Baum em ee Order by goul_dese J) where syno_=10)5

You might also like