0% found this document useful (0 votes)
17 views8 pages

Ch4 Question Bank With Back Exercise Solutions

This document contains questions and answers about SQL and database concepts. It defines SQL, describes single table queries and their uses, and the functions of the SELECT statement including displaying fields, sorting, and performing calculations. It also defines comparison/relational operators, Boolean operators, clauses like BETWEEN, IN, LIKE, and ORDER BY. Aggregate functions including AVG, MAX, MIN, SUM and COUNT are defined. The GROUP BY and HAVING clauses are also explained. Joins and sample queries involving tables are provided.

Uploaded by

pragunjain2010
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)
17 views8 pages

Ch4 Question Bank With Back Exercise Solutions

This document contains questions and answers about SQL and database concepts. It defines SQL, describes single table queries and their uses, and the functions of the SELECT statement including displaying fields, sorting, and performing calculations. It also defines comparison/relational operators, Boolean operators, clauses like BETWEEN, IN, LIKE, and ORDER BY. Aggregate functions including AVG, MAX, MIN, SUM and COUNT are defined. The GROUP BY and HAVING clauses are also explained. Joins and sample queries involving tables are provided.

Uploaded by

pragunjain2010
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/ 8

Chapt er-4

Struct uredQuer yLanguage( SQL)


Q1: -Def i
neSQL.
Ans: -I tisapr ogr ammi ngl anguagedesi gnedf or
the r etrieval and management of r elat
ional
dat abase.
Q2: -Whati ssi nglet abl equer y?
Ans: -Si nglet able quer i
es aret he quer ies that
extr actdat af rom onet ableonly.
Q3: -Whati ssel ectst atementusedf or?
Ans: -I ti susedt oext ractrecordsf r
om oneor
mor et ables.
Q4: -Howar esi nglet abl equeriesusef ul
?
Ans:Si ngl etabl equer iesar eusef ultogai nav i
ew
oft hedat ainat abl ethat :
1. Onl ydisplaycer tainfiel
dsint hequer yresult
.
2. Sor t
st her ecor dsi napar ti
cularorder .
3. ( Findsum, av erage)orper form calculati
ons
onpar ti
cul arcol umns.
4. Br i
ngtoget herdat afrom mul ti
pletable.
Q5: -Whatar ethef unct i
onsofsel ectstatement ?
Ans: Thef unct i
onsar e
1. Onl ydisplaycer t
ainf ieldsint hequer yresul
t.
2. Sor tsther ecordsi napar ticularor der.
3. ( Findsum, average)orper form cal culati
ons
onpar ticularcolumns.
4. Br ingt oget herdat af rom mul ti
pletabl e.
Q6: -Whati st he f unct ion off rom cl ause in
SELECTst atement ?
Ans: -I ti ndicatest het abl e(s)from whi chdat ais
tober etr i
eved.
Q7: -Whati st hef unct i
onofWHEREcl ausei n
SELECTst atement ?
Ans: itspeci fi
est hecondi ti
on, whi chrest ri
ctsthe
rowsr etur nedbyt hequer y.
Q8: -Gi vet hesy ntaxofSELECTst atement .
Ans :SELECT <Fi eld1, f
ield2,f ield3…..> FROM
<tabl e_ name>
Q9: -whatar ecompar i
son/ r
elati
onal operators?
Ans: Compar i
son/ relationaloper atorsar eused
tocompar ev aluesandgi vesther esultinei t
her
trueorf alse.Eg.<, >,=,>=,<=,<>.
Q10: -Whatar eBool eanOper ators?Def i
net hem.
Ans: -
Booleanoper ator
sar eusedt ocombi net wo
ormor econdi ti
onsandr esultisal waysineither
trueorf alse.Forexampl eAND, OR.
AND: -Thi s oper atort akes t wo condi ti
ons as
i
nputandr etur nsTr ueifbot ht hecondi ti
onsar e
Trueot her wisei tretur
nsf al
se.
OR: -Thisoper atortakest wocondi ti
onsasi nput
andr eturnsTr ueifanyorbot ht hecondi ti
onsar e
True.
Q11: -Defi
neBet ween-Andoper ator.
Ans: -Thisi susedt ogi vear angewi thi
nWHERE
clause.Ther angei ncludesbot ht helowerv alue
andt heupperv alue.
Q12: -Defi
neI Noper at
or .
Ans: -Wi tht he I N oper ator
,t he l i
stist o be
speci fi
edi nbr ackets.Thel i
sti t
emsshoul dbe
separ atedbycommas.I tmat chest hefiel
dv alue
wi t
ht hev aluesspeci f
iedi nthelistanddi splays
themat chingr ecords.Thedat e/st ri
ngsv alues
shoul
dbeencl
osedi
nsi
ngl
equot
es.

Q13:-Def i
neLi keOperat or
.
Ans:-Thi si susedwi thspeci alpat t
er nint he
expression.Theexpr essionshoul dbeencl osed
i
nquot es.I thast wowi ldcardchar acters:
*:
-itindicateszer oormor echar act ers.
?:
-itindicatesonl yonechar act er.
Q14:-Def i
neor derbyclause.
Ans:-Thi si s used t o sor tt he r ecords in
ascending or descendi ng or derbased on a
parti
cularf i
eld.
Q15:-What ar e aggr egate f unct ions? Def i
ne
dif
ferentt ypesofaggr egatef unct ions.
Ans:-Thisi s used t o cal culatet he summar y
values.Di f
ferentaggregatef unct i
onsar e:
1)AVG( ):
-t hi
scal cul
atest heav eragev al
ueofa
givenfield.
2)Max ():
-Thi scalcul
at esthemaxi mum v alueof
agi v
enf iel
d.
3.Min():
-Thiscal cul
atest hemi ni mum v alueofa
givenf ield.
4.Sum( ):-This cal culat
es t he sum v alue ofa
givenf ield.
5.Count ():-Thiscount st hetotalno.ofv aluesin
agi venf ield.
Q16: -Def ineGr oupByandHav i
ngCl ause.
Ans:-Gr oupBy :-Thi si susedt or etr
iever ows
hav i
ngcommonv aluesi ntoasetofr ows.
Hav i
ngCl ause:-t heHav ingclausei nGr oupBy
speci f
iest hecondi ti
on,whi chr estr
ictsther ows
returnedbyt hequer y.
Q17: -Whatar eJoi ns?
Ans:-Joi ns combi ne t wo or mor et ables to
retri
ev edat af rom mul tipletables,basedona
commonf i
eldbet weent hem.
Exercise:
Q5: -
a)Sel ect*f rom st udent
b)Sel ectName, Classf rom Student
c)SelectAgef r
om st udentwher eName=‘ Ram’
d)Sel ectaddr essf rom st udentwher eName=

Ram’
LabEx er
cise
Q2:-a)Selectnamef
rom Result
Wher eNameli
ke‘S*’

b)sel
ect*fr
om r
esul
t
wheremaths>90

c)select*f
rom r
esul
t
orderbyname

Q3:
-soluti
on
1)Select*from empl oyee
2)Select*from empl oyee
Wheredept=20
3)Select*from empl oyee
Wher eSal>30000
4)SelectEnamef rom empl oy
ee
Wher ejob=’cl
erk’
6)SelectEname, Jobf r
om employ
ee
7)
sel
ectdept,count(
* )f
r om employ
ee
Gr
oupbydept
8)selectdept ,j
ob, sum( salary)from empl oyee
Groupbydept, job
9)select dept , max( salary)-mi n(
salary
) f rom
empl oyee
Groupbydepthav ingsal >25000
10.sel ect*from empl oyeeor derbydoj
11.selectename, job,sal,
deptf rom empl oyee
Orderbysal arydesc
12.selectcount(* )from empl oy ee
Wher edept =10ordept =20
13.selectmax( sal)from empl oy ee
14.selectdept,sum( sal )
,avg(sal),max(sal)
,min(
sal)
fr
om empl oyeegr oupbydept
15.sel ectjob,count (
*)f rom empl oyeegr oupby
j
ob
Hav i
ngj ob=”cl
erk”
16.select*from empl oyee
Wher edeptI N(10,20,30)
17.selectenamef r
om empl oyee
Wher eenamel i
ke‘ S*’
18.selectename, salf r
om empl oy ee
Wher esalbet ween25000and40000
19.sel
ect*f rom empl oy
ee
Wher ejob=’manager ’orsal>30000
20.sel
ectenamef rom empl oyee
Wher eenamel i
ke‘*i
*’
21.sel
ect*f rom empl oyee
Wher esal>5000anddept =20
22.select*from empl oyee
Wher eename<>1001
23.sel
ectename, deptfrom employee

You might also like