ECET 450 Practice Exercise #6 Oracle Joins and Sub Queries
QUERIES
- 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.
- File Format: .sql, .lst (Output file)