Está en la página 1de 7

Assignment description.

Language: Access SQL.


Level: Basic.
Price: 80$
Programming Assignment.
You are given the following SLB database, which contains three tables
S!"#$, L%A$,
an& BA$'. (he SLB &atabase is &ownloa&able fro) the online s*llabus on
the blac+boar&.,
Problem
"o the following -roble)s. .an& in SQL /ueries as well as their results.
1. (/t01, List the S$A2# of all stu&ents with no loans.
2. (/t03, List S$A2#, A4# an& SL#5#L of all stu&ents in a given
SL#5#L onl* if at least one stu&ent in
that slevel has A4#677.
3. (/t08, List the S$A2# for all stu&ents with s8i-9:8;0; or who have a
loan with a ban+ that has
b8i-9:8;0;. (<f necessar*, s-lit the /uer* into several /ueries. Also, if there
are na)es re-eate& )ore
than once, ignore it.,
4. =(/t0;0, List B<" of ban+s of t*-e >SL> an& the B<" an& A2%!$ of
loans which &o not belong to
those ban+s.
5. (/t0;;, List S<", S$A2# an& B<" for stu&ents sharing their S?<@ with a
ban+.
Bonus Problems
6. (/t0;7, List B<" of all ban+s sharing their B?<@ with another ban+.
7. =(/t0;A, List S$A2# an& A4# of all stu&ents of a given SL#5#L onl* if
ever*one at hisBher SL#5#L
is 70 *ears of age or *ounger.
Notes
Cor -roble) ; *ouDll nee& a L#C E%<$ F an& the G.#H# clause
shoul& contain the con&ition Ili& <S $!LLJ.
@roble) A sa*s >List B<" of ban+s of t*-e KSLD an& the B<" an&
A2%!$ of loans which &o not belong to those
ban+s.> Ghat &oes it )eanL Gell, if there are two SL ban+s, sa* M an& Y, the
/uer* has to list for M all the loans
it &i&nNt issue (inclu&ing those issue& b* Y, an& list for Y all the loans it
&i&nNt issue (inclu&ing ...M,. o solve this
-roble), *ou nee& a E%<$ between two tables (< wonNt sa* which, where the
con&ition for )atch is that the B<" in
one table will be Knot e/ualD (IO6J, to the B<" in the other table.
%ne wa* to go about solving -roble) 1 is to Poin table Ban+ with itself
(on b8i-,, an& then figure out a wa* to get
rea& of rows having the sa)e ban+ twice (because ever* ban+ will be in the
sa)e 8i- co&e of itself,.
%ne wa* to solve -roble) 3 is using a *-e << e)be&&e& /uer*. he inner
/uer* woul& loo+ for stu&ents having
age O6 70 at a given slevel, an& if the answer to the inner /uer* is e)-t*
(i.e., $% #M<SS,, the outer /uer*
shoul& &o the rest ...
olution.
!as" 1
(/t01, List the S$A2# of all stu&ents with no loans.
#L$
S#L#Q sna)e
CH%2 (stu&ent S L#C E%<$ loan L %$ S.si&9L.si&,
G.#H# li& is $!LLR
#uer% &esult$
Query1
sname
JONES
SANDS
!as" 2
(/t03, List S$A2#, A4# an& SL#5#L of all stu&ents in a given SL#5#L
onl* if at least one stu&ent in that slevel has A4#677.
#L$
S#L#Q sna)e, age, slevel
CH%2 stu&ent S;
G.#H# #M<SS
(S#L#Q =
CH%2 stu&ent S7
G.#H# S7.slevel9S;.slevel
A$" S7.age677
,
%H"#H BY slevel, ageR
#uer% &esult$
#uer%1
sna
me
ag
e
sle
vel
JONE
S
23 4
CAB
EEN
24 5
WAT
SON
29 5
!as" 3
(/t08, List the S$A2# for all stu&ents with s8i-9:8;0; or who have a loan
with a ban+ that has b8i-9:8;0;. (<f necessar*, s-lit the /uer* into several
/ueries. Also, if there are na)es re-eate& )ore than once, ignore it.,
#L$
S#L#Q "<S<$Q(sna)e,
CH%2 stu&ent S
G.#H# s8i-9:8;0;
%H #M<SS
(S#L#Q =
CH%2 loan L
G.#H# L.si& 9 S.si&
A$" bi& <$
(S#L#Q bi&
CH%2 ban+
G.#H# b8i-9:8;0;
,
,
%H"#H BY sna)eR
#uer% &esult$
#uer%1
snam
e
ALLEN
ALTER
SANDS
!as" 4
=(/t0;0, List B<" of ban+s of t*-e >SL> an& the B<" an& A2%!$ of loans
which &o not belong to those ban+s.
#L$
S#L#Q B.bi&, L.bi&, L.a)ount
CH%2 ban+ B, loan L
G.#H# B.bt*-e9>SL>
A$" L.bi&O6B.bi&
%H"#H BY B.bi&, L.bi&, L.a)ount
#uer% &esult$
Query1
B.bid L.bid amount
CAPITAL FIDELITY 2 100,00.
CAPITAL FIDELITY 2 200,00.
CAPITAL HOME 1 200,00.
CAPITAL PEOPLES 1 000,00.
Query1
B.bid L.bid amount
CAPITAL PEOPLES 1 900,00.
CAPITAL PEOPLES 2 500,00.
CAPITAL PEOPLES 3 000,00.
CAPITAL SEAFIRST 2 000,00.
HOME FIDELITY 2 100,00.
HOME FIDELITY 2 200,00.
HOME PEOPLES 1 000,00.
HOME PEOPLES 1 900,00.
HOME PEOPLES 2 500,00.
HOME PEOPLES 3 000,00.
HOME SEAFIRST 2 000,00.
!as" 5
(/t0;;, List S<", S$A2# an& B<" for stu&ents sharing their S?<@ with a
ban+.
#L$
S#L#Q si&, sna)e, bi&
CH%2 stu&ent, ban+
G.#H# s8i-9b8i-
%H"#H BY si&, sna)e, bi&
#uer% &esult$
Query1
sid sname bid
6793SANDS FIDELITY
6793SANDS SEAFIRST
9735ALLEN FIDELITY
9735ALLEN SEAFIRST
!as" 6
(/t0;7, List B<" of all ban+s sharing their B?<@ with another ban+.
#L$
S#L#Q B;.bi&
CH%2 ban+ B;, ban+ B7
G.#H# B;.b8i-9B7.b8i-
A$" B;.bi&O6B7.bi&
#uer% &esult$
Query1
bid
SEAFIRST
FIDELITY
!as" 7
=(/t0;A, List S$A2# an& A4# of all stu&ents of a given SL#5#L onl* if
ever*one at hisBher SL#5#L is 70 *ears of age or *ounger.
#L$
S#L#Q sna)e, age
CH%2 stu&ent S;
G.#H# $% #M<SS
(S#L#Q =
CH%2 stu&ent S7
G.#H# S7.slevel9S;.slevel
A$" S7.age 6 70
,
%H"#H BY sna)e, ageR
#uer% &esult$
#uer%1
snam
e
ag
e
ALTER 19

También podría gustarte