You are on page 1of 13

243196661.

doc
Scenario CREATE TABLE dept( deptno INT default 99 NOT NULL PRIMARY KEY,
location ARC!AR("#$$
deptno location
%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%
&## Au'u(n !ill)
&&# *+ite !ill)
&"# Bloo,-eld !ill)
CREATE TABLE e,p(
e,pno INT NOT NULL PRIMARY KEY,
deptno INT NOT NULL RE.ERENCE/ dept(deptNO$,
la)tna,e C!AR("#$$
e,pno deptno la)tna,e
%%%%%%%%%%% %%%%%%%%%%% %%%%%%%%
&# &## Mol)on
0# &## *olf)on
1# &## 2la)),an
&
3ELETE .ROM e,p
"
3ELETE .ROM dept *!ERE location 4 5C+e((6 !ill)5
7
3ELETE .ROM dept *!ERE deptno 8 &"#
0
3ELETE .ROM dept *!ERE deptno BET*EEN 99 AN3 &&#
1
3ELETE .ROM dept *!ERE deptno 4 &# The tables' structure, contents, and scenario's
statements are given. Question Referring to the Emp and Dept table definitions and contents
in the scenario above, which statement executed independently will fail? This uestion covers
your !nowledge of deletion as well as Referential "ntegrity in #$% ueries. Choice 1 &ifth This
is not correct. The statement will run o!ay because there is no deptno'(), and that is why it is
not referenced from emp table. Choice 2 -- Correct (not selected) &ourth This is correct. The
statement will fail because dept'()) is referenced by the records from emp table. Choice 3
#econd This is not correct. "t will run fine. #uch a record does not exist and is not referenced.
Choice 4 -- Incorrect (selected) &irst This is not correct. "t will run fine. *ny record from emp
can be deleted. Choice 5 Third This is not correct. The statement will run o!ay because
dept+(,) are not referenced by any record of emp table. References Transact-#$%, .illiam
/. *mo pp.()0-()1 #$% #erver 2 Developer's 3uide, 4ichael 5tey and 6aul /onte #$% for
#marties7 *dvanced #$% 6rogramming, 8oe /el!o "94 D9, :niversal Database, ;ersion 2.(
Table EMP
e,pno dept 9o' )ala(6 co,,
%%%%%% %%%%%% %%%%%%%% %%%%%%%%% %%%%%%%%%%
&# BBB de:elope( ;####<## <##
"# BBB )ale)(ep =####<## &####<##
7# CAA d'a >####<## &###<##
0# CAA ?e',a)te( 0####<## 0####<##
1# @@@ ?e',a)te( 0####<## ;####<##
Page 1 of 13
243196661.doc
/ELECT EMP<EMPNO, EMP</ALARY, 3IN.O<A2/ALARY, 3IN.O<3MAA
.ROM EMP, (/ELECT 3EPT, A2(/ALARY$ A/ A2/ALARY, MAA(/ALARY$ A/ 3MAA
.ROM EMP *!ERE 3EPT B4 5@@@5 2ROUP BY 3EPT $ A/ 3IN.O
*!ERE EMP<COB IN (5de:elope(5, 5d'a5$
AN3 EMP<3EPT 4 3IN.O<3EPT
OR3ER BY EMPNO The contents of the table and the #$% statement are provided in the
sample. Question Referring to the E46 table and uery above, what result set will the uery
deliver? This uestion covers your !nowledge of #$% ueries used to derive tables. Choice 1
&# ;####<## 0####<###### 0####<##
7# >####<## 0####<###### 0####<## This is not correct.. 9y mista!e, DE6T ' <===< was
used . Choice 2 &# ;####<## =1###<###### ;####<##
7# >####<## =####<###### >####<##
0# 0####<## =####<###### >####<## This is not correct. Do not consider <webmaster< in
the subuery. Choice 3 -- Correct (not selected) &# ;####<## =1###<## ;####<##
7# >####<## =####<## >####<## This is correct. The solution is straightforward. &irst,
resolve the subuery, which plays the role of a derived table. Then resolve the main uery.
Choice 4 -- Incorrect (selected) 7# >####<## =####<## >####<##
&# ;####<## =1###<## ;####<## This is not correct. This is not the correct order of the
records. Choice 5 &# ;####<## =1###<###### ;####<##
7# >####<## =####<###### >####<##
0# 0####<## =####<###### >####<##
1# 0####<## 0####<###### 0####<## This is not correct. 9y mista!e, <webmaster< from
DE6T <===< was included in the calculations. References #$% for #marties7 *dvanced #$%
6rogramming, 8oe /el!o pp.,>) #$% #erver 2 Developer's 3uide, 4ichael 5tey and 6aul /onte
Transact-#$%, .illiam /. *mo "94 D9, :niversal Database, ;ersion 2.(
?our answer was CORRCT! Scenario 3ept
CREATE TABLE dept(
deptno INT 3E.AULT 7## NOT NULL PRIMARY KEY,
location ARC!AR("#$ 3E.AULT 5.e(ndale5,
)e(:e(Id C!AR(>$ 3E.AULT 5AY@&=5
$
E,p
CREATE TABLE e,p(
e,pno INT NOT NULL PRIMARY KEY,
deptno INT NOT NULL RE.ERENCE/ dept(deptNO$,
-()tDna,e C!AR("#$,
la)tDna,e C!AR("#$
$
&
IN/ERT INTO dept :alue)(NULL, 5/out+-eld5, 5E6F"15$
"
IN/ERT INTO e,p :alue)(&#, &#, 5Rac+el5, 5*i)e5$
7
IN/ERT INTO e,p :alue)("#, &"#, 5Ti,5, 5/no?5$
0
IN/ERT INTO dept :alue)(&"#, 5/out+-eld5, 5ABC"5$ The Dept and Emp DD% and the #$%
statements are presented. Question *fter tables Dept and Emp are created using the /reate
Page 2 of 13
243196661.doc
statements in the scenario above, which seuence of "nsert statements succeeds? This uestion
covers your !nowledge of inserting and Referential "ntegrity in #$% ueries. Choice 1 ,, >
This is not correct. ,-- "@#ERT statement conflicted with /5%:4@ &5RE"3@ AE? constraint >--
This is fine. Choice 2 >, , This is not correct. >-- This is fine. ,-- "@#ERT statement conflicted
with /5%:4@ &5RE"3@ AE? constraint. Choice 3 (, , This is not correct. (-- ?ou cannot
insert the value @:%% into column <deptno.< The column does not allow @:%%s. ,-- "@#ERT
statement conflicted with /5%:4@ &5RE"3@ AE? constraint Choice 4 B, > This is not
correct. *s the second "@#ERTstatement, the third "@#ERT statement conflicted with /5%:4@
&5RE"3@ AE? constraint. Choice 5 -- Correct (selected) >, B This is correct. >-- *fter
deptno (,) is inserted into Dept, the Emp record referring to it is inserted without a problem
Cstatement BD. References Transact-#$%, .illiam /. *mo pp.()0-()1, (,(-(,> #$% #erver 2
Developer's 3uide, 4ichael 5tey and 6aul /onte #$% for #marties7 *dvanced #$%
6rogramming, 8oe /el!o
Table Ta'le .a,ilie)
fno lna,e nGid)
%%%%%%%%% %%%%%% %%%%%%%%%%
&# Mida) &"
"# Linc+ 0
7# Mo(Han "
0# *itte( 7
1# 2atti &
=# /c(ooHe NULL
Ta'le 2ift)I
Hno fno
%%%%%%%% %%%%%%%%%%%
&## &#
&## "#
"## 7#
7## 0#
7## 1#
7## =#
/ELECT fno, Hno .ROM 2ift) *!ERE fno IN
(/ELECT fno .ROM .a,ilie) *!ERE nGid) 8 "$
OR3ER BY fno The tables and #$% in uestion are presented. Question Referring to the
above tables and uery, what result is delivered? This uestion tests your !nowledge of using "n
and @ot in wE subueries. Choice 1 -- Incorrect (selected) &# &##
"# &##
7# "##
0# 7##
1# 7## This is not correct. <+' )< could be used to get this result. Choice 2 -- Correct (not
selected) &# &##
"# &##
0# 7## This is correct. This is the correct column order. Choice 3 7# "##
1# 7##
=# 7## This is not correct. @5T "@ was used. Choice 4 &# &##
"# &##
7# "##
0# 7## This is not correct. <+' ,< was used instead of <+,.< Choice 5 &## &#
&## "#
7## 0# This is not correct. &irst column <fno,< then <gno< References Transact-#$%, .illiam
/. *mo pp.,)(-,),,,)F-,)0 #$% #erver 2 Developer's 3uide, 4ichael 5tey and 6aul /onte
Page 3 of 13
243196661.doc
#$% for #marties7 *dvanced #$% 6rogramming, 8oe /el!o "94 D9, :niversal Database,
;ersion 2.(
Scenario Ta'le T&
c&
%%%%%%%%%%%
#
"
7
&
CREATE IE* :& A/ /ELECT J .ROM t&
&
3ELETE .ROM TABLE t&
"
3ELETE .ROM IE* :&
7
3ELETE .ROM t& *!ERE c& 8 ANY(&, "$
0
3ELETE c& .ROM t&
1
3ELETE J .ROM t& /ontents of the table T( and the #$% statements are presented in the
sample. Question Referring to table T( in the scenario above, which #$% statements are
syntactically "@/5RRE/T? This uestion covers your !nowledge of deletion in #$% ueries.
Choice 1 -- Correct (not selected) All )tate,ent) a(e inco((ect< This is correct. #yntax is
violated for all the #$% statements. Choice 2 3ELETE .ROM TABLE t&
3ELETE .ROM IE* :& This is not correct. The correct one is -- DE%ETE &R54 t(. ;( is an
updatable view, and correct syntax is -- DE%ETE &R54 v(. Choice 3 3ELETE J .ROM t&
This is not correct. The correct one is -- DE%ETE &R54 t(. Choice 4 3ELETE .ROM t&
*!ERE c& 8 ANY(&, "$ This is not correct. #ubuery should be used. Choice 5 -- Incorrect
(selected) 3ELETE c& .ROM t& This is not correct. The correct one is -- DE%ETE &R54 t(.
References Transact-#$%, .illiam /. *mo pp.()0-()1 #$% #erver 2 Developer's 3uide,
4ichael 5tey and 6aul /onte #$% for #marties7 *dvanced #$% 6rogramming, 8oe /el!o "94
D9, :niversal Database, ;ersion 2.(
SQ" CREATE TABLE P(o'e (c& INT PRIMARY KEY$
in)e(t into P(o'e :alue)(null$
in)e(t into P(o'e :alue)(&$
in)e(t into P(o'e :alue)(#$
in)e(t into P(o'e :alue)(&$ The table structure and the #$% statements are presented.
Question .hat is the content of 6robe after running all the #$% statements above? This
uestion covers your !nowledge of inserting and Referential "ntegrity in #$% ueries. Choice
1 c( --- @:%% ( ) This is not correct. The insertion of @:%% will fail because of primary !ey
constraint violation. *s a primary !ey, column c( does not allow @:%%. Choice 2 -- Correct
(not selected) c( --- ) ( This is correct. The first <(< is inserted. The second insertion of <(< will
fail because of primary !ey constraint violation by a duplicate value. Choice 3 c( --- @:%% ( )
( This is not correct. @:%% and the second <(< will fail the inserts. The insertion of @:%% will fail
because of primary !ey constraint violation. *s a primary !ey, column c( does not allow @:%%.
The second insertion of ( will fail because of primary !ey constraint violation by a duplicate
Page 4 of 13
243196661.doc
value. Choice 4 c( --- ( ) ( This is not correct. The second insertion of <(< will fail because of
primary !ey constraint violation by a duplicate value. Choice 5 -- Incorrect (selected) c( --- )
This is not correct. The first <(< will be inserted too. References Transact-#$%, .illiam /.
*mo pp.()0-()1, (,(-(,> #$% #erver 2 Developer's 3uide, 4ichael 5tey and 6aul /onte #$%
for #marties7 *dvanced #$% 6rogramming, 8oe /el!o
Table Ta'le t&&I
c&
%%%%%%%
"
7
1
NULL
Ta'le t"&I
c&
%%
"
1
0
/ELECT t&&<c&, t"&<c& c" .ROM t&& LE.T OUTER COIN t"& ON t&&<c&4t"&<c& OR3ER
BY t&&<c& Table content and the #$% in uestion are presented in the sample. Question
Referring to tables t(( and t,( above, what is the result of the uery? This uestion covers an
understanding of the 5:TER 85"@. Choice 1 c& c"
%% %%%%
NULL #
" "
7 #
1 1 This is not correct. @:%% is placed in the values of the t,(.c( missing in the left table t((.c(.
Choice 2 c& c"
%% %%%%
NULL NULL
" "
1 1 This is not correct. *ll values of t(.c( must participate in the result set. ;alue B is missing.
Choice 3 c& c"
%% %%%%
" "
7 NULL
1 1 This is not correct. *ll values of t(.c( must participate in the result set. @:%% is missing.
Choice 4 -- Incorrect (selected) c& c"
%% %%%%
" "
1 1 This is not correct. *ll values of t(.c( must participate in the result set. ;alue B and @:%%
are missing. Choice 5 -- Correct (not selected) c& c"
%% %%%%
NULL NULL
" "
7 NULL
1 1 This is correct. This is a strict application of the rules. References Transact-#$%, .illiam
/. *mo pp.(1,-(11 #$% #erver 2 Developer's 3uide, 4ichael 5tey and 6aul /onte #$% for
#marties7 *dvanced #$% 6rogramming, 8oe /el!o
Page 5 of 13
243196661.doc
Table
!R e,pDid dept )eE )al %%%%%% %%%% %%%% %%%%%%%%%%%%%%% & A M >####<## 7 A . "####<##
0 A . "1###<## 1 B M 1####<## = B . =####<## > C . 9####<## 9 3 M ;####<##
&# E M 9####<## /ELECT 3I/TINCT dept .ROM +( A/ +(& *!ERE )eE45.5 AN3 )al K
ALL (/ELECT a:H()al$ .ROM +( A/ +(" *!ERE +("<dept4+(&<dept$ OR3ER BY dept
The tables and #$% in uestion are presented.
Question
Referring to the table above, which departments will the uery return?
This uestion tests your !nowledge of subueries.
Choice 1
*, 9
This is not correct. "n dept 9, females get more money than males.
Choice 2
E
This is not correct. There are no females in dept E.
Choice 3
/, D
This is not correct. The only female cannot get less than average salary in dept /. There are
no females in dept D.
Choice 4 -- Correct (selected)
*
This is correct. 5nly dept <*< has females whose salary is less than the department's average.
<*%%< is not needed in the uery because the correlated subuery returns one row per row of
main uery.
Choice 5
9
This is not correct. "n dept 9, females get more money than males.
References
Transact-#$%, .illiam /. *mo pp.,),-,)B #$% #erver 2 Developer's 3uide, 4ichael 5tey
and 6aul /onte #$% for #marties7 *dvanced #$% 6rogramming, 8oe /el!o "94 D9, :niversal
Database, ;ersion 2.(
Top of &orm (
9ottom of &orm (
Scenario CREATE TABLE dept"7(
deptno INT default 99 NOT NULL PRIMARY KEY,
location ARC!AR("#$ default 53efault C(eeG5,
)e(:e(Id C!AR(>$ default 5E6F5
$
Ta'le 3ept"7I
deptno location )e(:e(Id
%%%%%%%%%%% %%%%%%%%%%%%% %%%%%%%%
Page 6 of 13
243196661.doc
&## /out++ill, MI ABC&
&&# Ro6al Maple, MI ABC&
&"# Bi(,ida,, MI ABC"
CREATE TABLE e,p"7(
e,pno INT NOT NULL PRIMARY KEY,
deptno INT NOT NULL RE.ERENCE/ dept"7(deptNO$, %% ON 3ELETE RE/TRICT,
-()tna,e C!AR("#$, la)tna,e C!AR("#$$
Ta'le E,p"7I
e,pno deptno -()tna,e la)tna,e
%%%%%% %%%%%% %%%%%%%%%% %%%%%%%%%%%%
&# &## Mole Mol)on
"# &"# To, T+o,)on
7# &"# Aa(on A(on)on
0# &## NULL T*olf)on
1# &## Lea+ 2(a)),an
&
UP3ATE e,p"7 /ET deptno 4 &#& *!ERE deptno4&##
"
UP3ATE dept"7 /ET deptno 4 &&& *!ERE deptno4&&#
7
UP3ATE dept"7 /ET deptno 4 &"& *!ERE deptno4&"#
0
UP3ATE dept"7 /ET deptno 4 9> *!ERE deptno499 The tables and #$% in uestion are
presented. Question Referring to the scenario above, which set of :pdate statements run
successfully? This uestion tests your !nowledge of :pdates and referential integrity in
advanced #$% ueries. Choice 1 -- Correct (not selected) ,, > This is correct. "n both cases,
updated dept,B.deptno C((( and 10D were not referenced by emp,B.deptno. Choice 2 B, >
This is not correct. "n number B, the :6D*TE statement conflicted with the /5%:4@
RE&ERE@/E constraint. Choice 3 ,, B This is not correct. "n number B, the :6D*TE
statement conflicted with the /5%:4@ RE&ERE@/E constraint. Choice 4 -- Incorrect
(selected) (, , This is not correct. "n number (, the :6D*TE statement conflicted with the
/5%:4@ &5RE"3@ AE? constraint. Choice 5 (, B This is not correct. "n number's ( and B,
the :6D*TE statements conflicted with the /5%:4@ RE&ERE@/E constraint. References
Transact-#$%, .illiam /. *mo pp.(>)-(>( #$% #erver 2 Developer's 3uide, 4ichael 5tey and
6aul /onte #$% for #marties7 *dvanced #$% 6rogramming, 8oe /el!o "94 D9, :niversal
Database, ;ersion 2.(
Scenario CREATE TABLE e,p"7(
e,pno INT NOT NULL PRIMARY KEY,
deptno INT NOT NULL RE.ERENCE/ dept(deptNO$,
%% ON 3ELETE CA/CA3E ON UP3ATE RE/TRICT,
-()tna,e C!AR("#$,
la)tna,e C!AR("#$
$
Ta'le E,p"7I
e,pno deptno -()tna,e la)tna,e
Page 7 of 13
243196661.doc
%%%%%% %%%%%%%% %%%%%%%%%% %%%%%%%%%%%%%%%%%%%%
&# &## Mole Mol)on
"# &"# To, T+o,)on
7# &"# Aa(on A(on)on
0# &## NULL *olf)on
1# &## Lea+ 2(a)),an
CREATE TABLE dept"7(
deptno INT 3E.AULT 99 NOT NULL PRIMARY KEY,
location ARC!AR("#$,
)e(:e(Id C!AR(>$
$
deptno location )e(:e(Id
%%%%%%% %%%%%%%%% %%%%%%
&## /out++ill, MI ABC&
&&# Ro6al Maple, MI ABC&
&"# Bi(,ida,, MI ABC"
&
UP3ATE dept"7 /ET deptno 4 deptnoL& *!ERE deptno BET*EEN &#& AN3 &&&
"
UP3ATE e,p"7 /ET deptno 4 &7# *!ERE la)tna,e LIKE 5@M5
7
UP3ATE dept"7 /ET deptno 4 deptnoL&#
0
UP3ATE dept"7 /ET location 4 location L 5, MI5
1
UP3ATE e,p"7 /ET deptno 4 &7# *!ERE la)tna,e LIKE 5*M5 The tables and #$% in
uestion are presented. Question Referring to the scenario above, which set of :pdate
statements will cause data to be modified? This uestion tests your !nowledge of :pdates and
referential integrity in advanced #$% ueries. Choice 1 ,, B This is not correct. @umber , has
no rows that ualify for update. The number B :6D*TE statement conflicted with the /5%:4@
RE&ERE@/E constraint. Choice 2 ,, > This is not correct. @umber , has no rows that ualify
for update. Choice 3 -- Correct (not selected) (, > This is correct. @umber ( is o!ay because
no deptno ()( - (()G ((( is not referenced. Choice 4 -- Incorrect (selected) (, , This is not
correct. @umber ( is o!ay because no deptno ()( - (()G ((( is not referenced. @umber , has no
rows that ualify for update. Choice 5 B, H This is not correct. The number B :6D*TE
statement conflicted with the /5%:4@ RE&ERE@/E constraint. The number H :6D*TE
statement conflicted with the /5%:4@ &5RE"3@ AE? constraint. References Transact-#$%,
.illiam /. *mo pp.(>)-(>( #$% #erver 2 Developer's 3uide, 4ichael 5tey and 6aul /onte
#$% for #marties7 *dvanced #$% 6rogramming, 8oe /el!o "94 D9, :niversal Database,
;ersion 2.(
Scenario Ta'le T&I
c&
%%%
#
&
NULL
=
Page 8 of 13
243196661.doc
"
Ta'le T"I
c&
%%%
&
"
7
0 The tables and #$% in uestion are presented. Question Referring to the tables T( and T,
in the scenario above, which one of the following statements delivers the greatest number of
rows? This uestion tests your !nowledge of using *ny and *ll. Choice 1 select I from t(
where c( + *@? Cselect c( from t,D This is not correct. Two rows are retrieved. Choice 2
select I from t( where c( + *@? Cselect c( from t, where c( "# @:%%D This is not correct. =ero
rows are retrieved. Choice 3 -- Incorrect (selected) select I from t( where c( + *%% Cselect
c( from t,D This is not correct. 5ne row is retrieved. Choice 4 select I from t( where c( +
Cselect maxCc(D from t,D This is not correct. 5ne row is retrieved. Choice 5 -- Correct (not
selected) select I from t( where c( + *%% Cselect -c( from t,D This is correct. The subuery
returns negative values, so all rows from t(, except with @:%%, will be selected C> rows totalD.
References Transact-#$%, .illiam /. *mo pp.,)F-,)0 #$% #erver 2 Developer's 3uide,
4ichael 5tey and 6aul /onte #$% for #marties7 *dvanced #$% 6rogramming, 8oe /el!o "94
D9, :niversal Database, ;ersion 2.(
SQ" )elect a<lna,e,a<fna,e f(o, a
9oin ' on a<lna,e4'<lna,e
?+e(e '<)eE 4 5,ale5 * select #$% statement is presented in the sample. Question .hich
uery produces the same results as the uery above? This uestion covers the two different
syntax approaches to coding a Join. Choice 1 )elect lna,e,fna,e f(o, a ?+e(e lna,e
in
()elect lna,e f(o, '$ This is incorrect because all values of lname will be returned from b
whether or not sex ' 'male'. Choice 2 -- Correct (selected) )elect a<lna,e,fna,e f(o,
a,' ?+e(e
a<lna,e4'<lna,e and '<)eE45,ale5 This is correct. This is another way to code a Join. "t is
euivalent to the original uery. Choice 3 )elect lna,e,fna,e f(o, a This is incorrect
because it does not select only the rows from table * that have a corresponding row in table 9
and where b.sex''male'. Choice 4 )elect lna,e,fna,e f(o, a ?+e(e lna,e in
()elect lna,e f(o, a 9oin ' on
lna,e ?+e(e )eE45,ale5$ This is incorrect because the subuery does not give a complete
Join predicate, such as a.lname ' b.lname. Choice 5 )elect a<lna,e,fna,e f(o,
a 9oin ' ?+e(e '<)eE45,ale5 This is incorrect because it does not specify the Join criteria.
References The /omplete Reference #$%, by 8ames R. 3roff and 6aul @. .einberg CThe
4c3raw-Kill /ompanies, (110D, "#9@7 ))2,((0>H0 pp. (F,-(F>, (2>-(22
Scenario Ta'le T#&I
c&
%%%
&
"
7
0
&
Cu)t (un t+e Nue(6
"
IN/ERT INTO T#& ALUE/(&$
Page 9 of 13
243196661.doc
and (un t+e Nue(6
7
IN/ERT INTO T#" ALUE/(&$
and (un t+e Nue(6
0
IN/ERT INTO T#& ALUE/(&$
IN/ERT INTO T#& ALUE/(&$
and (un t+e Nue(6
1
IN/ERT INTO T#" ALUE/(NULL$
and (un t+e Nue(6
Ta'le T#"I
c&
%%%
&
"
7
0
/ELECT CA/E *!EN COUNT(J$ 4 # T!EN 53o not coincide5 EL/E 5Coincide5 EN3
.ROM t#& *!ERE
(/ELECT COUNT(3I/TINCT t#&<c&$ .ROM t#&$ 4 (/ELECT COUNT(3I/TINCT t#&<c&$
.ROM t#& INNER COIN t#" ON t#&<c& 4 t#"<c&$
AN3
(/ELECT COUNT(3I/TINCT t#"<c&$ .ROM t#"$ 4 (/ELECT COUNT(3I/TINCT t#"<c&$
.ROM t#" INNER COIN t#& ON t#&<c& 4 t#"<c&$ /ontent of the tables T)( and T), is
presented in the sample. The uery is executed after statements in the given conditions.
Question Referring to tables T)( and T), in the scenario above, which ueries will produce the
output <Do not coincide?< This uestion covers an understanding of the 5:TER 85"@. Choice
1 -- Correct (not selected) *ll of the ueries will yield </oincide.< This is correct. *fter execution
of any data manipulation statements, the tables contain the same set of distinct values.
Choice 2 Three This is not correct. 5nly the correct choice is complete. *fter execution of *@?
and *%% data manipulation statements, the tables contain the same set of distinct values.
Choice 3 Two This is not correct. 5nly the correct choice is complete. *fter execution of *@?
and *%% data manipulation statements, the tables contain the same set of distinct values.
Choice 4 -- Incorrect (selected) &ive This is not correct. 5nly the correct choice is complete.
*fter execution of *@? and *%% data manipulation statements, the tables contain the same set of
distinct values. @:%% is ignored by D"#T"@/T. Choice 5 &our This is not correct. 5nly the
correct choice is complete. *fter execution of *@? and *%% data manipulation statements, the
tables contain the same set of distinct values. References Transact-#$%, .illiam /. *mo
pp.(1,-(11 #$% #erver 2 Developer's 3uide, 4ichael 5tey and 6aul /onte #$% for #marties7
*dvanced #$% 6rogramming, 8oe /el!o "94 D9, :niversal Database, ;ersion 2.(
Sa#$le Code CREATE TABLE T">(c INT$
CREATE TABLE T"9(c INT$ This is a #$% uery. Question Referring to the sample code
above, which one of the following ueries runs successfully? This uestion covers usage of
select in advanced #$% ueries. Choice 1 /ELECT J, (/ELECT c .ROM t"9 *!ERE t"9<c
84 t"><c$ a) ,in7 .ROM t"> This is not correct. The subuery returned more than ( value.
This is not permitted when a subuery is used as an expression. Choice 2 /ELECT J,
(/ELECT ,in(c$, & .ROM t"9 *!ERE t"9<c 84 t"><c$ a) ,in7 .ROM t"> This is not
Page 10 of 13
243196661.doc
correct. 5nly one expression can be specified in the select list when the subuery is not
introduced with EL"#T#. Choice 3 -- Correct (not selected) /ELECT J, (/ELECT MIN(c$
LMIN(c$ a) ,in" .ROM t"9 *!ERE t"9<c 84 t"><c$ a) ,in7 .ROM t"> This is correct.
The subuery returns ( value. This is needed when a subuery is used as an expression.
Choice 4 -- Incorrect (selected) /ELECT J, (/ELECT MIN(c$, MIN(c$ a) ,in" .ROM t"9
*!ERE t"9<c 84 t"><c$ a) ,in7 .ROM t"> This is not correct. 5nly one expression can be
specified in the select list when the subuery is not introduced with EL"#T#. Choice 5
/ELECT J, (/ELECT /UM(c$ .ROM t"9 *!ERE t"9<c 84 t"><c 2(oup B6 c$ a) ,in7
.ROM t"> This is not correct. The subuery returns more than ( value. This is not permitted
when a subuery is used as an expression. References #$% #erver 2 Developer's 3uide,
4ichael 5tey and 6aul /onte pp.>>H-H)2 Transact-#$%, .illiam /. *mo #$% for #marties7
*dvanced #$% 6rogramming, 8oe /el!o "94 D9, :niversal Database, ;ersion 2.(
Scenario Ta'le T&9I
cno cnt
%%%%%%%%%%% %%%%%%%%%%%
& &
& "
" &
7 0
7 1
7 9
0 99
/ELECT J .ROM t&9 *!ERE EAI/T/
(/ELECT J .ROM t&9 t *!ERE t&9<cno 4 t<cno
AN3 t&9<cnt 8 t<cnt$ The table and #$% in uestion are presented. Question .hich rows
are selected from Table T(1 in the scenario above? This uestion tests your !nowledge of #$%
subueries. Choice 1 & "
7 0
7 1
7 9
0 99 This is not correct. *ll rows are selected except those having the smallest cnt. Choice 2
-- Correct (not selected) & "
7 1
7 9 This is correct. The uery lists duplicate rows, which have the same cno values, except the
rows with the biggest cnt. Choice 3 & &
& "
" &
7 0
7 1 This is not correct. <M'< was used instead of <M<. Choice 4 No (o?) a(e )elected< This
is not correct. There are rows that ualify for selection. Choice 5 -- Incorrect (selected) & &
7 0
7 1 This is not correct. Kere, the rows with the smallest cnt values for a given cno are selected
for multiple rows per sno. References Transact-#$%, .illiam /. *mo pp.,),-,)B #$% #erver
2 Developer's 3uide, 4ichael 5tey and 6aul /onte #$% for #marties7 *dvanced #$%
6rogramming, 8oe /el!o "94 D9, :niversal Database, ;ersion 2.(
Sa#$le Code Ta'le E,p9I
e,pno dept da6D)al edDle:el
%%%%%% %%%%%%%% %%%%%%% %%%%%%%%%%%
&# &## 1#<## &#
"# &## 0#<## &0
7# "## 7#<## &1
0# "## 0#<## &1
1# 7## NULL &&
Page 11 of 13
243196661.doc
=# 7## 7#<## &;
;# 7## 0#<## &=
/ELECT e,pno, dept, da6D)al, edDle:el .ROM e,p9 A/ cu(De,p
*!ERE
cu(De,p<dept B4 7## AN3
cu(De,p<da6D)al 8 ANY
(/ELECT e,p<da6D)al .ROM e,p9 e,p
*!ERE e,p<dept 4 7##
AN3 cu(De,p<edDle:el K4 e,p<edDle:el
AN3 e,p<da6D)al I/ NOT NULL
$
OR3ER BY e,pno The tables and #$% in uestion are presented. Question Referring to the
sample code above, what is the outcome of the uery? This uestion tests your !nowledge of
using *ny and *ll. Choice 1 O/u'Nue(6 (etu(ned ,o(e t+an & :alueO ,e))aHe This is
not correct. < + < is used in the place of <*@?.< Choice 2 &# &## 1#<## &# This is not
correct. <*%%< is used in the place of <*@?.< Choice 3 E,pt6 )et This is not correct.
Department for comparison used was ()) instead of B)). Choice 4 &# &## 1#<## &#
"# &## 0#<## &0 This is not correct. Department for comparison used was ,)) instead of B)).
Choice 5 -- Correct (selected) &# &## 1#<## &#
"# &## 0#<## &0
0# "## 0#<## &1 This is correct. The uery lists the employees outside of dept B)) whose
salary is greater than salary of any employee of dept B)) and whose education level is not
higher. References Transact-#$%, .illiam /. *mo pp.,)F-,)0 #$% #erver 2 Developer's
3uide, 4ichael 5tey and 6aul /onte #$% for #marties7 *dvanced #$% 6rogramming, 8oe /el!o
"94 D9, :niversal Database, ;ersion 2.(
Table Ta'le ToolD9o'I
toolDid 9o'Did
%%%%%%% %%%%%%%%
& #
& &
& "
" &
7 &
7 "
7 7
0 0
Ta'le Co')I
9o'Did
%%%%%%
#
&
"
7
0
/ELECT 3I/TINCT toolDid .ROM toolD9o' t9& *!ERE NOT EAI/T/
(/ELECT J .ROM 9o') 9 *!ERE NOT EAI/T/
(/ELECT J .ROM toolD9o' t9" *!ERE t9"<9o'Did 4 9<9o'Did AN3 t9"<toolDid B4
t9&<toolDid$
$ The tables and #$% in uestion are presented. Question Referring to the table above, to
what uestion does the uery respond? This uestion tests your !nowledge of Exists, and @ot
Page 12 of 13
243196661.doc
Exists. The uery loo!s for tools for which there are no Jobs that other tools cannot do. "n other
words, we are loo!ing for the tools that can be substituted by other tools for the given Jobs.
Choice 1 -- Incorrect (selected) Display all listed tools that cannot do at least some of the listed
Jobs. This is not correct. The uery see!s for generic tools. Choice 2 Display all listed tools
that can do all of the listed Jobs. This is not correct. The uery see!s for generic tools. Choice
3 -- Correct (not selected) Display all listed tools for which exist other tool that can do its Job.
This is correct. 5nly for tool , exist other tools C( and BD that can do its Job. *ll other tools can do
uniue Jobs. Choice 4 Display all listed tools that can do all of the listed Jobs. This is not
correct. The uery see!s for generic tools. Choice 5 Display all listed tools that can do at least
some of the Jobs that other tools can do. This is not correct. The uery see!s for generic tools.
References Transact-#$%, .illiam /. *mo pp.,)B-,)F #$% #erver 2 Developer's 3uide,
4ichael 5tey and 6aul /onte #$% for #marties7 *dvanced #$% 6rogramming, 8oe /el!o "94
D9, :niversal Database, ;ersion 2.(
Page 13 of 13

You might also like