Index for SQL Name: VIKAS
AGNIHOTRI
Class: XII
- B
Roll NO. -
Consider the tables given below and answer the questions that follow: No 1 2 3 4 5 $ %
Table: Employee Name Mukul Kritika Naveen Uday Nu"ur Mks! &!elly
Dept 10 20 30
DName &ales inan/e Ad)in
Salary 30000 35000 32000 38000 32000 3%000 3$000
Zone West Centre West Nrt! #ast &ut! Nrt!
Table: Department inSal 25000 30000 25000
Age 28 30 40 38 2$ 28 2$
a!Sal 32000 50000 40000
Grade A A
C ' A
Dept 10 10 20 30 20 10 30
"#D 1 5 %
Write SQL commands to: Create Table / Insert Into 1( Crea Create te t!e t!e ab abve ve tab table less and and inse insert rt tu" tu"le less in t!e) t!e)(( Simple Select 2( *is" *is"lay lay t!e t!e det detai ails ls + all all t!e t!e e)"l e)"ly yees ees((
3(
*is"lay *is"lay t!e &alary &alary,, -ne -ne,, and and .rad .radee + all t!e t!e e)"l e)"lye yees( es(
4(
*is"lay *is"lay t!e t!e re/rds re/rds + all all t!e e)"lyees e)"lyees aln aln it! t!eir t!eir annual annual salar salaries( ies( T!e T!e &alary &alary /lu)n /lu)n + t!e t!e table /ntains )nt!ly salaries + t!e e)"lyees( T!e ne /lu)n s!uld be iven t!e na)e Annual &alary( Conditional Select using Where Clause 5( *is"lay *is"lay t!e detail detailss + all all t!e t!e e)"ly e)"lyees ees ! ! are are bel bel 30 years years + ae( ae( $(
*is"lay *is"lay t!e salari salaries es + + all all t!e t!e e)"l e)"lye yees es + + de"ar de"art)e t)ent nt 10( 10(
40
$sing N$%% %( *is"lay *is"lay t!e detail detailss + all t!e e)"ly e)"lyees ees !se !se .rad .radee is is NU NU((
8(
*is"lay *is"lay t!e detail detailss + all t!e e)"ly e)"lyees ees !s !see .rade .rade is nt nt NU NU((
$sing DISTINCT Clause 6( *is"lay *is"lay t!e t!e na)es na)es + varius varius 7nes 7nes +r) +r) t!e t!e table table #)"ly #)"lyee( ee( A 7ne na)e s!uld s!uld a""ear a""ear nly n/e(
10(
*is"lay *is"lay t!e t!e variu variuss de"art)e de"art)ent nt nu)bers nu)bers +r) t!e t!e table table #)"ly #)"lyee( ee( A de"art)en de"art)entt nu)ber nu)ber s!uld s!uld be dis"layed nly n/e( $sing %ogical #perators &N#T' AND' #() 11( 11( *is"lay *is"lay t!e details details + + all all t!e t!e e)"ly e)"lyees ees + + de"art) de"art)ent ent 10 10 ! ! are abve abve 30 years + ae( ae( 12(
*is"lay *is"lay t!e t!e detail detailss + all all t!e t!e e)"ly e)"lyees ees ! ! are ettin ettin a salary salary + )re )re t!an t!an 35000 35000 in in t!e t!e de"art)ent 30( 13( *is"lay *is"lay t!e deta details ils + + all t!e t!e e)"ly e)"lyees ees !se !se sala salary ry is bete beteen en 32000 32000 and and 38000 38000(( 14( *is"lay *is"lay t!e details details + + all all t!e t!e e)"ly e)"lyees ees !se !se rade is bete beteen en A9 A9 and C9( $sing IN #perator 15( *is"lay *is"lay t!e t!e na)es na)es + all t!e t!e e)"ly e)"lyees ees ! ! are rkin rkin in in de"art)e de"art)ent nt 20 r 30( 30( Usin Usin ;N "eratr< "eratr< 1$( *is"lay *is"lay t!e t!e na)es na)es and salaries salaries + + all t!e e)"ly e)"lyees ees ! ! are are rkin rkin neit! neit!er er in We West st 7ne 7ne nr in Centre 7ne( Usin ;N "eratr< $sing *ETWEEN #perator 1%( *is"lay *is"lay t!e deta details ils + + all t!e t!e e)"ly e)"lyees ees !se !se sala salary ry is bete beteen en 32000 32000 and and 38000 38000(( Usin '#TW##N "eratr< 18( *is"lay *is"lay t!e details details + + all all t!e t!e e)"ly e)"lyees ees !se !se rade is bete beteen en A9 A9 and C9( Usin '#TW##N "eratr< $sing %I+E #perator 16( *is"lay *is"lay t!e na)e na)e,, salary salary,, and ae ae + all all t!e e)"l e)"lye yees es !se !se na)e na)ess start start it! it! M9( M9( 20( *is"lay *is"lay t!e na)e na)e,, salary salary,, and and ae + + all t!e t!e e)"l e)"lye yees es !se !se na)e na)ess end it! it! a9( a9( 21( *is"lay *is"lay t!e na)e, salary, salary, and and ae ae + all t!e e)"lyees e)"lyees !se !se na)es d nt nt /nta /ntain in a9 a9 $sing Aggregate ,unctions 22( *is"lay *is"lay t!e su) and avera averaee + t!e salari salaries es + + all all t!e t!e e)"l e)"lye yees( es( 23( *is"lay *is"lay t!e !i! !i!est est and t!e t!e les lestt salari salaries es bein bein "aid "aid in in de"art de"art)en )entt 10( 24( *is"lay *is"lay t!e nu)ber nu)ber + e)" e)"ly lyees ees rkin rkin in in de"a de"art) rt)ent ent 10( 10( $sing #(DE( *- clause 25( *is"lay *is"lay t!e deta details ils + + all t!e t!e e)"ly e)"lyees ees in t!e t!e as/en as/endin din rder rder + t!eir t!eir sala salarie ries( s( 2$( *is"lay *is"lay t!e deta details ils + + all t!e t!e e)"ly e)"lyees ees in in t!e des/ des/end endin in rde rderr + t!eir t!eir na)e na)es( s( 2%( *is"lay *is"lay t!e t!e detail detailss + all all t!e t!e e)"ly e)"lyees ees in t!e as/end as/endin in rder rder + t!eir t!eir rades rades and it!i it!in n rades rades in in t!e des/endin rder + t!eir salaries( $sing G(#$. *- clause 28( *is"lay *is"lay t!e ttal ttal nu)ber nu)ber + e)" e)"ly lyees ees in ea/! ea/! de"a de"art) rt)ent ent(( 26( *is"lay *is"lay t!e averae averae ae ae + e)"lyees e)"lyees in in ea/! ea/! de"art) de"art)ent ent nly nly +r t!se t!se de"art) de"art)ents ents in !i/! !i/! averae ae is )re t!an 30( $sing $.DATE' DE%ETE' A%TE( TA*%E 30( 30( =ut =ut t!e t!e rad radee ' +r +r all all t!s t!see ! !se se ra rade de is is NU NU(( 31( ;n/rea ;n/rease se t!e t!e sala salary ry + + all all t!e t!e e)"l e)"lye yees es abve abve 30 years years + ae ae by 10>( 10>( 32( *elete *elete t!e t!e re/r re/rds ds + + all t!e t!e e)"l e)"lyee yeess !se !se rad radee is C and and salary salary is is bel bel 30000 30000((
41
33( Add ant! ant!er er /lu /lu)n )n ?ire ?ire*a *ate te + + ty"e ty"e *ate *ate in t!e t!e #)"l #)"ly yee ee tabl table( e( Creating and $sing IEWs 34( Create Create a vie vie West West@-n @-nee !i/! !i/! dis"l dis"lays ays t!e t!e re/rds re/rds + + e)"lyee e)"lyeess rkin rkin in Wes Westt 7ne( 7ne( 35( Create Create a vie vie Abve@3 Abve@30 0 !i/! !i/! dis"lay dis"layss t!e re/rd re/rdss + nly t!se t!se e)"lye e)"lyees es ! ! are abve 30 years years + ae( 3$( *is"lay *is"lay t!e t!e re/rds re/rds + t!e t!e e)"lyees e)"lyees +r) t!e vie vie Abve@30 Abve@30 ! rk rk in in t!e &ales de"art)ent de"art)ent(( 0#IN o, t1o tables 3%( *is"lay *is"lay t!e detail detailss + all all t!e t!e e)"ly e)"lyees ees ! ! rk rk in &ale &aless de"art de"art)en )ent( t( 38( *is"lay *is"lay t!e Na)e Na)e and and *e"ar *e"art)e t)ent nt Na)e Na)e + all t!e e)"ly e)"lyees ees(( D(#. TA*%E' TA*%E' D(#. IEW 36( 36( *r" r" t! t!e vie vie s /re /reat ated ed abv abve( e( 40( 40( *r" *r" t!e t!e tab table less #)" #)"l lye yeee and and *e"a *e"art rt)e )ent nt((
42
Creat Cre ate e table table/i /ins nsert ert into into msql! C"#$%# %$&L# em'loee( )! no int(1*+ )! name char(10*+ )! salar int(10*+ )! ,one char(10*+ )! age int(2*+ )! grade char(1*+ )! de't int(2**msql! ./S#"% ./% em'loee )!$L#S(1+3muul3+50000+3west3+26+3$3+10*msql! ./S#"% ./% em'loee )!$L#S(2+3ritia3+57000+3centre3+50+3$3*msql! ./S#"% ./% em'loee )!$L#S(5+3naveen3+52000+3west3+40+3 3+20*msql! ./S#"% ./% em'loee )!$L#S(4+3uda3+56000+3north3+56+3C3+50*msql! ./S#"% ./% em'loee )!$L#S(7+3nu'ur3+52000+3east3+28+3 3+20*msql! ./S#"% ./% em'loee )!$L#S(8+3mosh3+59000+3south3+26+3&3+10*msql! ./S#"% ./% em'loee )!$L#S(9+3shell3+58000+3north3+28+3$3+5*msql! C"#$%# C"#$%# %$&L# de'artment( )! d't int(2*+ 45
)! dname char(10*+ )! minsal int(10*+ )! masal int(10*+ )! ;< int(1**Quer =+ 0 rows a>ected (0?84 sec* msql! ./S#"% ./% de'artment )!$L#S(10+3sales3+27000+52000+1*msql! ./S#"% ./% de'artment )!$L#S(20+3@nance3+50000+70000+7*msql! ./S#"% ./% de'artment )!$L#S(50+3admin3+27000+40000+9*-
1)
Simple select
msql! S#L#C% A )!B" em'loeeD))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D E no E name E salar E ,one E age E grade E de't E D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D E 1 E muul muul E 50000 E west E 26 E $ E 10 E E 2 E ritia E 57000 E centreE 50 E $ E 10 E E 5 E naveen E 52000 E west E 40 E E 20 E E 4 E uda E 56000 E north E 56 E C E 50 E E 7 E nu'ur E 52000 E east E 28 E E 20 E E 8 E mosh E 59000 E south E 26 E & E 10 E E 9 E shell E 58000 E north E 28 E $ E 50 E D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D 9 rows in set (0?05 sec*
msql! S#L#C% salar+,one+grade 44
)!B" em'loeeD))))))))D))))))))D)))))))D E salar E ,one E grade E D))))))))D))))))))D)))))))D E 50000 50000 E west E $ E E 57000 E centre E $ E E 52000 E west E E E 56000 E north E C E E 52000 E east E E E 59000 E south E & E E 58000 E north E $ E D))))))))D))))))))D)))))))D 9 rows in set (0?00 sec*
msql! S#L#C% name+salarA12 $nnualFSalar+,one+age+grade+de't )!B" em'loee
D)))))))))D))))))))))))))D))))))))D))))))D)))))))D))))))D E name E $nnualFSalar E ,one E age E grade E de't E D)))))))))D))))))))))))))D))))))))D))))))D)))))))D))))))D E muul E 580000 E west E 26 E $ E 10 E E ritia E 420000 E centre E 50 E $ E 10 E E naveen E 564000 E west E 40 E E 20 E E uda E 478000 E north E 56 E C E 50 E E nu'ur E 564000 E east E 28 E E 20 E E mosh E 444000 E south E 26 E & E 10 E E shell E 452000 E north E 28 E $ E 50 E D)))))))))D))))))))))))))D))))))))D))))))D)))))))D))))))D 9 rows in set (0?00 sec*
2) Conditional Select using where Clause msql! S#L#C% A 47
)!B" em'loee )!W;#"# ageG50D))))))D))))))))D))))))))D)))))))D))))))D)))))))D))))))D E no E name E salar E ,one E age E grade E de't E D))))))D))))))))D))))))))D)))))))D))))))D)))))))D))))))D E 1 E muul muul E 50000 E west E 26 E $ E 10 E E 7 E nu'ur E 52000 E east E 28 E E 20 E E 8 E mosh E 59000 E south E 26 E & E 10 E E 9 E shell E 58000 E north E 28 E $ E 50 E D))))))D))))))))D))))))))D)))))))D))))))D)))))))D))))))D 4 rows in set (0?05 sec* msql! S#L#C% salar )!B" em'loee )!W;#"# de'tH10D))))))))D E salar E D))))))))D E 50000 E E 57000 E E 59000 E D))))))))D 5 rows in set (0?00 sec*
3)
Using null
msql! S#L#C% A )!B" em'loee )!W;#"# gradeH3 3D))))))D))))))))D))))))))D))))))D))))))D)))))))D))))))D E no E name E salar E ,one E age E grade E de't E D))))))D))))))))D))))))))D))))))D))))))D)))))))D))))))D E 5 E naveen E 52000 E west E 40 E E 20 E E 7 E nu'ur E 52000 52000 E east E 28E E 20 E D))))))D))))))))D))))))))D))))))D))))))D)))))))D))))))D 2 rows in set (0?00 sec* 48
msql! S#L#C% A )!B" em'loee )!W;#"# grade is /% /LLD))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D E no E name E salar E ,one E age E grade E de't E D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D E 1 E muul muul E 50000 E west E 26 E $ E 10 E E 2 E ritiaE 57000 E centre E 50E $ E 10 E E 5 E naveen E 52000 E west E 40 E E 20 E E 4 E uda E 56000 E north E 56 E C E 50 E E 7 E nu'ur E 52000 E east E 28 E E 20 E E 8 E mosh E 59000 E south E 26 E & E 10 E E 9 E shell E 58000 E north E 28E $ E 50 E D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D 9 rows in set (0?00 sec*
4)
Using distinct clause msql! S#L#C% <.S%./C% ,one )!B" em'loee-
D))))))))D E ,one E D))))))))D E west E E centre E E north E E east E E south E D))))))))D 7 rows in set (0?05 sec* msql! S#L#C% <.S%./C% de't )!B" em'loeeD))))))D E de't E D))))))D 49
E 10 E E 20 E E 50 E D))))))D 5 rows in set (0?00 sec*
5) Using logical logic al operators(N! operato rs(N!"" #N$" %) msql! S#L#C% A )!B" em'loee )!W;#"# de'tH10 $/< age!50#m't set (0?00 sec* msql! S#L#C% A )!B" em'loee )!W;#"# salar!57000 $/< de'tH50D))))))D))))))))D))))))))D)))))))D))))))D)))))))D))))))D E no E name E salar E ,one E age E grade E de't E D))))))D))))))))D))))))))D)))))))D))))))D)))))))D))))))D E 4 E uda E 56000 E north E 56 E C E 50 E E 9 E shell E 58000 E north E 28 E $ E 50 E D))))))D))))))))D))))))))D)))))))D))))))D)))))))D))))))D 2 rows in set (0?00 sec* msql! S#L#C% A )!B" em'loee )!W;#"# salar!H52000 $/< salarGH56000D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D E no E name E salar E ,one E age E grade E de't E D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D E 2 E ritia E 57000 E centre E 50 E $ E 10 E E 5 E naveen E 52000 E west E 40 E E 20 E E 4 E uda E 56000 E north E 56 E C E 50 E E 7 E nu'ur E 52000 E east E 28 E E 20 E 46
E 8 E mosh E 59000 E south E 26 E & E 10 E E 9 E shell E 58000 E north E 28 E $ E 50 E D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D 8 rows in set (0?00 sec* msql! S#L#C% A )!B" em'loee )!W;#"# grade!H3$3 $/< gradeGH3C3D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D E no E name E salar E ,one E age E grade E de't E D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D E 1 E muul muul E 50000 E west E 26 E $ E 10 E E 2 E ritia E 57000 E centre E 50 E $ E 10 E E 4 E uda E 56000 E north E 56 E C E 50 E E 8 E mosh E 59000 E south E 26 E & E 10 E E 9 E shell E 58000 E north E 28 E $ E 50 E D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D 7 rows in set (0?02 sec*
&)
Using Usi ng 'N oper opertat tator or
msql! S#L#C% name )!B" em'loee )!W;#"# <#I% ./(20+50*D))))))))D E name E D))))))))D E naveen E E uda E E nu'ur E E shell E D))))))))D 4 rows in set (0?05 sec* msql! S#L#C% name+salar )!B" em'loee )!W;#"# ,one /% ./(3west3+3centre3*4J
D))))))))D))))))))D E name E salar E D))))))))D))))))))D E uda E 56000 E E nu'ur E 52000 E E mosh E 59000 E E shell E 58000 E D))))))))D))))))))D 4 rows in set (0?00 sec*
)
Using Us ing *!+* *!+**N *N operat ope rator or
msql! S#L#C% A )!B" em'loee )!W;#"# salar %W##/ 52000 $/< 56000D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D E no E name E salar E ,one E age E grade E de't E D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D E 2 E ritia E 57000 E centre E 50 E $ E 10 E E 5 E naveen E 52000 E west E 40 E E 20 E E 4 E uda E 56000 E north E 56 E C E 50 E E 7 E nu'ur E 52000 E east E 28 E E 20 E E 8 E mosh E 59000 E south E 26 E & E 10 E E 9 E shell E 58000 E north E 28 E $ E 50 E D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D 8 rows in set (0?00 sec* msql! S#L#C% A )!B" em'loee )!W;#"# grade %W##/ 3$3 $/< 3C3D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D E no E name E salar E ,one E age E grade E de't E D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D E 1 E muul muul E 50000 E west E 26 E $ E 10 E E 2 E ritia E 57000 E centreE 50 E $ E 10 E E 4 E uda E 56000 E north E 56 E C E 50 E E 8 E mosh E 59000 E south E 26 E & E 10 E E 9 E shell E 58000 E north E 28 E $ E 50 E 70
D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D 7 rows in set (0?00 sec*
,)
Using -'.* operator
msql! S#L#C% name+salar+age )!B" em'loee )!W;#"# name L.=# KmKD)))))))D))))))))D))))))D E name E salar E age E D)))))))D))))))))D))))))D E muul E 50000 E 26 E E moshE 59000 E 26 E D)))))))D))))))))D))))))D 2 rows in set (0?00 sec* msql! S#L#C% name+salar+age )!B" em'loee )!W;#"# name L.=# KaKD)))))))))D))))))))D))))))D E name E salar E age E D)))))))))D))))))))D))))))D E ritia E 57000 E 50 E D)))))))))D))))))))D))))))D 1 row in set (0?00 sec* msql! S#L#C% name+salar+age )!B" em'loee )!W;#"# name /% L.=# Ka D))))))))D))))))))D))))))D E name E salar E age E D))))))))D))))))))D))))))D E muul E 50000 E 26 E E nu'ur E 52000 E 28 E 71
E mosh E 59000 E 26 E E shell E 58000 E 28 E D))))))))D))))))))D))))))D 4 rows in set (0?05 sec*
)
Using aggregate 0unctions
msql! S#L#C% S(salar*+$M(salar* )!B" em'loeeD)))))))))))))D)))))))))))))D E sum(salar* E avg(salar* E D)))))))))))))D)))))))))))))D E 240000 E 54267?9145 E D)))))))))))))D)))))))))))))D 1 row in set (0?00 sec* msql! S#L#C% $N(salar*+ ./(salar* )!B" em'loee )!W;#"# <#I%H10D)))))))))))))D)))))))))))))D E ma(salar* E min(salar* E D)))))))))))))D)))))))))))))D E 59000 E 50000 E D)))))))))))))D)))))))))))))D 1 row in set (0?00 sec* msql! S#L#C% C/%(A* )!B" em'loee )!W;#"# <#I%H10D))))))))))D E count(A* E D))))))))))D E 5E D))))))))))D 1 row in set (0?00 sec* 72
1) 1) Using Usi ng % %$*% $*% claus clause e msql! S#L#C% A )!B" em'loee )!"<#" &O salar $SCD))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D E no E name E salar E ,one E age E grade E de't E D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D E 1 E muul muul E 50000 E west E 26 E $ E 10 E E 5 E naveen E 52000 E west E 40 E E 20 E E 7 E nu'ur E 52000 E east E 28 E E 20 E E 2 E ritia E 57000 E centre E 50 E $ E 10 E E 9 E shell E 58000 E north E 28 E $ E 50 E E 8 E mosh E 59000 E south E 26 E & E 10 E E 4 E uda E 56000 E north E 56 E C E 50 E D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D 9 rows in set (0?02 sec* msql! S#L#C% A )!B" em'loee )!"<#" &O name <#SCD))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D E no E name E salar E ,one E age E grade E de't E D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D E 4 E uda E 56000 E north E 56 E C E 50 E E 9 E shell E 58000 E north E 28 E $ E 50 E E 7 E nu'ur E 52000 E east E 28 E E 20 E E 5 E naveen E 52000 E west E 40 E E 20 E E 1 E muul muul E 50000 E west E 26 E $ E 10 E E 8 E mosh E 59000 E south E 26 E & E 10 E E 2 E ritia E 57000 E centreE centreE 50 E E 10 E D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D 9 rows in set (0?00 sec* msql! S#L#C% A )!B" em'loee )!"<#" &O grade $SC + salar <#SC75
D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D E no E name E salar E ,one E age E grade E de't E D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D E 5 E naveen E 52000 E west E 40 E E 20 E E 7 E nu'ur E 52000 E east E 28 E E 20 E E 9 E shell E 58000 E north E 28 E $ E 50 E E 2 E ritia E 57000 E centre E 50 E $ E 10 E E 1 E muul muul E 50000 E west E 26 E $ E 10 E E 8 E mosh E 59000 E south E 26 E & E 10 E E 4 E uda E 56000 E north E 56 E C E 50 E D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D 9 rows in set (0?00 sec*
11) 11) Using Usi ng %U %U Claus Clause e msql! S#L#C% de't+ C/%(A* )!B" em'loee )!M"I &O de'tD))))))D))))))))))D E de't E count(A* E D))))))D))))))))))D E 10 E 5E E 20 E 2E E 50 E 2E D))))))D))))))))))D 5 rows in set (0?02 sec* msql! S#L#C% $M(age* )!B" em'loee )!M"I &O de't )!;$./M $M(age*!50D))))))))))D E avg(age* E D))))))))))D E 55?0000 E E 52?0000 E D))))))))))D 2 rows in set (0?00 sec* 74
12) 12 ) Us Usiing U$ U$#!* !*"" $*-* $* -*!* !* " #-!* #-!*% % table msql!I<$%# em'loee )!S#% gradeHP&P )!W;#"# grade is null2 rows in set(0?00 sec* msql!I<$%# em'loee )!S#% salar HsalarDsalarA10100 )!W;#"# age!502 rows in set(0?00 sec* msql!<#L#%# )!B" em'loee )!W;#"# gradeHPCP S$L$"OG50000em't set(0?00 sec* msql!$L%#" %$&L# em'loee )!$<< ;ire
13) 13) Crea Creati tin ng and usin sing '*+ '*+S S msql! C"#$%# .#W WestFRone )!$S S#L#C% A )!B" em'loee1 )!W;#"# ,oneHKwestKQuer =+ 0 rows a>ected (0?07 sec* msql! C"#$%# .#W $boveF50 )!$S S#L#C% A )!B" em'loee1 )!W;#"# age!50Quer =+ 0 rows a>ected (0?07 sec* msql! S#L#C% A )!B" WestFRoneD))))))D))))))))D))))))))D))))))D))))))D)))))))D))))))D))))))))))D E no E name E salar E ,one E age E grade E de't E ;ire
D))))))D)))))))))D))))))))D))))))))D))))))D E d't E dname E minsal E masal E ;< E D))))))D)))))))))D))))))))D))))))))D))))))D E 10 E sales E 27000 E 52000 E 1 E E 20 E @nance E 50000 E 70000 E 7 E E 50 E admin E 27000 E 40000 E 9 E D))))))D)))))))))D))))))))D))))))))D))))))D 5 rows in set (0?05 sec* msql! S#L#C% A )!B" $boveF50 78
)!W;#"# de't H 10#m't set (0?49 sec*
14) 7oin o0 two tables msql! S#L#C% A )!B" #m'loee1 e+ de'artment d )!W;#"# d?dname H 3sales3 -
79
D))))))D)))))))))D))))))))D))))))))D))))))D)))))))D))))))D)))))))))) D))))))D)))))))D))))))))D))))))))D))))))D E no E name E salar E ,one E age E grade E de't E ;ire
76
15) $rop table" drop 8iew msql! <"I .#W westF,oneQuer =+ 0 rows a>ected (0?00 sec* msql! <"I .#W aboveF50Quer =+ 0 rows a>ected (0?00 sec* msql! <"I %$&L# em'loee1 Quer =+ 0 rows a>ected (0?15 sec* msql! <"I %$&L# de'artmentQuer =+ 0 rows a>ected (0?7J sec*
7J