Sie sind auf Seite 1von 5

CIS 211C Oracle - Database Design and SQL HOMEWORK: #

D!E:

Run the following queries in Oracle Application Express. Paste a copy of each query Into this word document or notepad .txt file, save and return in class or via email Complete the following Try It / Solve It Exercises: Section 17, r!ctice "#i$e %!t!&!se %esign 'esson 1, Exercises 1, (, ), !n$ 7

1. The manager of Global Fast Foods would like to send out coupons for the upcoming sale. He wants to send one coupon to each household. Create the SELECT statement that returns the customer last name and a mailing address. 1. SELECT DISTINCT last_name, address,city, state, zip FROM _c!st"mers# $. Sue, ob, and !oni"ue were the emplo#ees of the month. $sing the f%staffs table, create a SELECT statement to displa# the results as shown in the Super Star chart. Super Star &&& Sue &&& Sue &&& &&& ob &&& ob &&& &&& !oni"ue &&& !oni"ue &&& $. SELECT %&&&%'' irst_name ''%&&&%'' irst_name''%&&&% (S )S!per Star) FROM _sta s# '. Global Fast Foods has decided to gi(e all staff members a ') raise. *repare a report that presents the output as shown in the chart. E!*L+,EE L-ST .-!E C$//E.T S-L-/, S-L-/, 01TH ') /-1SE

*. SELECT last_name (S )EM+LO,EE L(ST N(ME), salary (S )C-RRENT S(L(R,),salary & 1..* (S )S(L(R, /IT0 *1 R(ISE) F/+! f%staffs 2 3. The owners of 45s on 4emand would like a report of all items in their 4%C4s table with the following column headings6 1n(entor# 1tem, C4 Title, !usic *roducer, and ,ear *urchased. *repare this report. 2. SELECT cd_n!m3er (S )In4ent"ry Item), title (S )CD Title), pr"d!cer (S )M!sic +r"d!cer), year (S ),ear +!rc5ased) FROM d_cds #

Section 17, r!ctice "#i$e %!t!&!se %esign 'esson *, Exercises 1, *, ), +, !n$ 11

1. $sing the Global Fast Foods database, retrie(e the customer7s first name, last name, and address for the customer who uses 14 8'9. 1. SELECT irst_name, last_name, address FROM _c!st"mers /0ERE Id 6 7*8# 9. Show the name, start date, and end date for Global Fast Foods: promotional item ;ballpen and highlighter; gi(eawa#. 9. SELECT name, start_date, end_date, :i4e_a;ay FROM _pr"m"ti"nal_men!s /0ERE :i4e_a;ay 6 %3allpen and 5i:5li:5ter%# *. The manager of 45 on 4emand would like a report of all the C4 titles and #ears of C4s that were produced before <===. *. SELECT title, year FROM d_cds /0ERE year < 9...# =. 0rite a S>L statement that will displa# the student number ?studentno@ of an# student who has a *E maAor in the table named students. Title the studentno column Student .umber. =. SELECT st!dentn" (S )St!dent N!m3er) >(S is "pti"nal? FROM st!dents /0ERE ma@"r 6 %+E% # 11. 0rite a S>L statement that lists the Global Fast Foods emplo#ees who were born before BCD=. 11. SELECT irst_name, last_name FROM _sta s /0ERE 3irt5date < %.1AB(NA=.%#

Section 17, r!ctice "#i$e %!t!&!se %esign 'esson (, Exercises 1, (, ,, !n$ +

1. 4ispla# the first name, last name, and salar# of all Global Fast Foods staff whose salar# is between E'.== and EB=.== per hour. 1. SELECT irst_name, last_name, salary FROM _sta s /0ERE salary CET/EEN *... and 1....# $. $sing onl# the less than, e"ual, or greater than operators, rewrite the following "uer#6 SELECT first%name, last%name F/+! f%staffs 0HE/E salar# ET0EE. <=.== and 9=.==2 $. SELECT irst_name, last_name FROM _sta s /0ERE salary D6 9. and salary <68.# 8. Select all the +racle database emplo#ees whose last names end with ;s; Change the heading of the column to read *ossible Candidates 8. SELECT last_name (S )+"ssi3le Candidates) FROM empl"yees /0ERE last_name LIEE %1s%# =. 0rite a S>L statement that lists the songs in the 45s on 4emand in(entor# that are t#pe code 33, B<, or B. =. SELECT title FROM d_s"n:s /0ERE type_c"de IN > 22,19,1?#
Section 1+, r!ctice "#i$e %!t!&!se %esign 'esson 1, Exercises *, -, ), !n$ 7

9. 4ispla# the last names of all Global Fast Foods emplo#ees who ha(e ;e; and ;i; in their last names. 9. SELECT last_name FROM _sta s /0ERE last_name LIEE %1e1% (ND last_name LIEE %1i1%# 7. $sing the emplo#ees table, write a "uer# to displa# all emplo#ees whose last names start with ;4; and ha(e ;a; and ;e; an#where in their last name. 7. SELECT last_name FROM empl"yees

/0ERE last_name LIEE %D1a1e1% "r last_name LIEE %D1e1a%# *. 1n which (enues did 45s on 4emand ha(e e(ents that were not in pri(ate homesF *. SELECT l"c_type FROM d_4en!es /0ERE l"c_type NOT IN>%+ri4ate 0"me%?# For "uestions 3 and D, write S>L statements that will produce the desired output. 2. 0ho am 1F 1 was hired b# +racle after !a# BCCD but before 5une of BCCC. !# salar# is less than ED=== a #ear and 1 ha(e an ;en; in m# last name. 2. SELECT irst_name, last_name FROM empl"yees /0ERE last_name LIEE %1en1% and salary < =... and 5ire_date CET/EEN %.1AB-NA F=% (ND %$1AM(,AFF%# Diana L"rentz

Section 1+, r!ctice "#i$e %!t!&!se %esign 'esson *, Exercises 1, (, !n$ -

1. 1n the eGample below, assign the emplo#ee%id column the alias of ;.umber.; Complete the S>L statement to order the results set b# the column alias. SELECT emplo#ee%id, first%name, last%name F/+! emplo#ees2 1. SELECT empl"yee_id (S )N!m3er), irst_name, last_name FROM empl"yees ORDER C, )N!m3er)# $. +rder the 45 on 4emand songs b# descending title. $se the alias ;+ur Collection; for the song title. $. SELECT title (S )O!r C"llecti"n) FROM d_s"n:s ORDER C, title DESC# 7. 0rite a S>L statement using the +/4E/ , clause that could retrie(e the information needed. 4o not run the "uer#. 7. SELECT irst_name, last_name, st!dent_id, year_in_sc5""l, parGin:_space FROM st!dents /0ERE year_in_sc5""l 6 1 ORDER C, last_name, irst_name DESC# >eHact syntaH names ;ill 4ary?

Das könnte Ihnen auch gefallen