ECET450 Practice Exercise #6
Oracle Joins and Sub Queries
This exercise uses the same tables you have been using for your labs. Sign on to Oracle using your own user id and password.
Follow these steps to complete this exercise:
Write your queries in a script file.
Debug your script file either as you go along or after you finish writing all four queries.
Create a spooled or HTML output file using your script file. Be sure to SET ECHO ON before you create your spool output.
Submit the output file, the script file, and this exercise sheet with your name on it through the Dropbox.
Using the traditional join method, write a query using the ORDERITEMS and BOOK tables to list the order number, book title, and retail amount of the book ordered. Format the retail amount to reflect dollars and cents using the correct function and give the retail amount column and alias of “Cost.”
Rewrite the query in #1, only this time, use a NATURAL JOIN operator to create the join. Your output should be the same.
Write a query using the BOOKS and PUBLISHER tables that will show all of the publishers’ names and related book titles, even those publishers who do not currently have any books listed in the BOOKS table. HINT: this will require an OUTER JOIN
Write a sub query using the BOOKS and PUBLISHER table to list the ISBN, book title, and the retail price for every book in the BOOKS table published by AMERICAN PUBLISHING. Format the book price to show a dollar sign and two decimal places by using the correct conversion function.
Write a sub query using the ORDERITEMS table that will return only the ISBN of the book that has been bought most often. This process will require you to obtain the maximum total number of books ordered (based on ISBN) and then compare that to total books ordered, grouped by ISBN. Remember that sub queries work from the bottom up so the process described here is starting with the second query, not the first (remember this exercise when doing #5 in the lab).
Turn the following in for a grade:
This lab sheet as a cover sheet with your name on it
Your script file with the five queries in it
The output file showing both the query and result set
Add this assignment (all three documents) to the zip file containing all assignments for this week.