SlideShare a Scribd company logo
1 of 3
CIS 336 Week 6 iLab 6 Devry University
Click this link to get the tutorial:
http://homeworkfox.com/tutorials/general-
questions/4156/cis-336-week-6-ilab-6-devry-university/
Lab 6 of 7:

Oracle Single Row and Group Functions (28 points) Lab #6 will introduce the various aspects of the
Single-Row and Group Functions available in the Oracle Database. Most functions can be used in either
the SELECT statement or the WHERE clause, but more commonly are used in the SELECT. Chapters 5 and
6 cover most all of the normal processing you use in these functions. In some cases, you will be asked to
used more than one function within a single SELECT statement. General Lab Information and
Considerations This lab will utilize the same set of tables found in the script file (LeeBooks.SQL) that
were used for Labs 4 and 5. Each query in the script file you will create must be numbered (use --1
comments for numbering) and in order. The SQL for the following exercises should be written using
notepad and run in SQL*Plus. Read each problem carefully and follow the directions as stated. A Clean
Script File: A script file is meant to be like a program. The file can be run every time the code needs to be
executed without having to retype the code again each time. For this reason, it is important that there
are no errors in the code inside the file. You can go back and forth between notepad and Oracle when
creating your script file to check your queries and verify if they work or not. However, you do not want
to create your final output file until after you have verified that everything in your script is correct by
running it, in its entirety at least once and viewing the output. Once this has been done, you can create
your final output file, with echo to create the document, you can turn in with your lab. Remember in
using a spool session, you must type "SPOOL OFF" at the SQL> prompt after your script stops spooling to
capture all of your data! Lab Do's and Don’t's * Do Not include the LEEBOOKS.SQL as part of your lab
script. o Do use Notepad to write your query script file. * Do Not write your queries in Word. o Do test
each query before moving on to the next. * Do Not include extra queries for a problem unless the
problem explicitly asks for more than one query. o Do test your queries before creating your final output
file. * Do Not turn in a script file that has queries with errors. o Do number each query using - -1
comment notation. * Do Not start your query on the same line as the comment. o Do remember to
check your final output and script file for accuracy. * Do Not turn in your lab without first checking your
output file to verify that it is correct. Things to keep in mind: If you are not sure of the table names in
your user schema, you can use the following select statement to list them. SELECT * FROM TAB; If you
want to know the name of the columns in a particular table you can use the following command to list
them. DESC Making a script file containing a series of describe statements for each table and then
spooling the output will give you a listing of all the tables with column names. Be sure to review and
verify your final output when you are finished. Do Not assume anything. Write queries for each of the
stated problems in the steps below that will return a result set of data to satisfy the requirements.
When finished, your script file should have a total of 13 queries, and your resulting output file should
show both the query and result set for each. Deliverables Submit for grading: 1. Your script file with the
13 queries in it. Be sure your name, course number, and lab number are in a comment area at the top of
your file. 2. An output file created using SET ECHO ON showing both the SQL code and the results. 3.
Both documents are to be zipped into a single file before submitting to the iLab Dropbox for Week 6

Week 6. L A B S T E P S

STEP 1: Back to top Using the BOOK_CUSTOMER table and the NVL function, create a query that will
return a list containing the customer number, first name, last name, and the characters ‘NOT REFERRED’
if the customer was not referred by another customer. Give the derived column an alias of REFERRED
BY. Do not list any customers that were referred by another customer.

STEP 2: Back to top Using the BOOKS table and the SUBSTR function, create a query that will return a list
of book ISBN codes and the book title for all the computer books. Format the ISBN code to display as 9-
999-99999-9 (e.g., 1059831198 would display as 1-059-83119-8)

STEP 3: Back to top Using the BOOKS table, create a query using the correct functions to return the
category name, the total retail of all books per category with a column alias of "Total Retail", and the
average retail of all the books per category with an alias of "Average Retail" for all categories with a total
retail greater than $40.00. Format the total retail and average retail columns using the correct function
to show dollars and cents with a dollar sign.

STEP 4: Back to top Using the correct tables in your schema, create a query using either join operation
you wish that will list the book title and number of authors for all books that have been written by more
than one author. Give the title column an alias of "Book Title" and the column showing the number of
authors an alias of "Number of Authors".

STEP 5: Back to top Using the BOOK_AUTHOR and AUTHOR tables for the upper most query, create a
sub query that will return the BOOKID, and the first and last name of the author(s) who have written the
book(s) that have been purchased the most. To successfully accomplish this, you will need to first find
out the maximum total number of copies (based on quantity) sold of a book (based on bookid) in the
ORDER_ITEMS table. This will be done in the bottom most query. The return from this query will be used
to compare against the BOOKID in the ORDER_ITEMS table that occurs an equal number of times in the
middle query. The return of this query will then be used to compare to a BOOKID related to an Author in
the tables of the top most query. (HINT: Be careful, you will need both GROUP BY and HAVING clauses
for your solution.)

STEP 6: Back to top Using the correct tables, create a sub query using either join operation you wish that
will list the customer number, first and last name concatenated together, and city for all customers who
have placed an order for the most expensive book (based on retail price). Give the combined customer
names column and alias of "Customer Name".

STEP 7: Back to top Using the ORDER_ITEMS table, create a query using the correct functions to return
the item#, the total quantity of items ordered with an alias of "Total", the average quantity per order
with an alias of "Average" (since averages are often in decimals, only show two decimal places), the
minimum quantity ordered with an alias of "Minimum", and the maximum quantity ordered with an
alias of "Maximum". Your output results set should have five columns and four rows of data.

STEP 8: Back to top Using the BOOKS table, create a query using the DECODE function that will display
the book title, the published date, and the publisher name (this is where the decode function comes in).
Give the publisher name column an alias of "Publisher Name", and order the publisher names in
descending order. The publisher names used should be the same as those in the PUBLISHER table. DO
NOT join to the Publisher table for this query.

STEP 9: Back to top Using the PUBLISHER table, create a query that will return a line of output like the
one below for each record in the table. Be sure to use the correct functions in the SELECT statement, so
that your output looks like the example below. The contact person for Printing Is Us Publishing is
Tommie Seymour. Be sure to use the correct function to display the publisher name and publisher
contact with only the first letter of each word capitalized.

STEP 10: Back to top Using the correct tables, create a query using the JOIN ON method to display a
listing of all customers who have purchased more than two books. List the customer’s last name, the
customer’s city and state, and the number of books they have purchased. Give the number purchased
column and alias of "Number Purchased".

STEP 11: Back to top Using only the BOOK table for the upper most statement, create a sub query that
will update the retail price of all books published by PRINTING IS US by five percent (retail * 1.05).
Remember, all you have is the publisher "name". Use the sub query to find the publisher ID. To verify
your update, provide a select statement on the BOOKS table before your update statement, and then a
second select on the BOOKS table after the update. Once you have verified the results, you can issue a
ROLLBACK statement to return the data to the original state.

STEP 12: Back to top Using the BOOK_CUSTOMER table, write a sub query that will return the names of
those customers who were referred by the same individual who referred Jorge Perez. Do not display
Jorge Perez’s name in the returned results (Hint: you should only have two customers displayed and the
exclusion for Jorge Perez must be associated with the upper query).

STEP 13: Back to top Using the BOOKS table, create a query using the correct functions to return the
category name, total number books per category with a column alias of "Category Total", and the total
cost of all the books per category with an alias of "Cost". Format the cost column using the correct
function to show dollars and cents with a dollar sign. This is the end of Lab #6 Back to top]HTML

More Related Content

More from CIS339

Cis336 all i labs week 1 to week 7 devry university
Cis336 all i labs week 1 to week 7 devry universityCis336 all i labs week 1 to week 7 devry university
Cis336 all i labs week 1 to week 7 devry universityCIS339
 
Cis336 week 1 i lab 1
Cis336 week 1 i lab 1Cis336 week 1 i lab 1
Cis336 week 1 i lab 1CIS339
 
Acc 460 final exam
Acc 460 final examAcc 460 final exam
Acc 460 final examCIS339
 
Cis336 week 1 i lab 1
Cis336 week 1 i lab 1Cis336 week 1 i lab 1
Cis336 week 1 i lab 1CIS339
 
Cis336 week 1 i lab 1
Cis336 week 1 i lab 1Cis336 week 1 i lab 1
Cis336 week 1 i lab 1CIS339
 
Cis336 week 2 i lab 2
Cis336 week 2 i lab 2Cis336 week 2 i lab 2
Cis336 week 2 i lab 2CIS339
 
Cis336 week 1 i lab 1
Cis336 week 1 i lab 1Cis336 week 1 i lab 1
Cis336 week 1 i lab 1CIS339
 

More from CIS339 (7)

Cis336 all i labs week 1 to week 7 devry university
Cis336 all i labs week 1 to week 7 devry universityCis336 all i labs week 1 to week 7 devry university
Cis336 all i labs week 1 to week 7 devry university
 
Cis336 week 1 i lab 1
Cis336 week 1 i lab 1Cis336 week 1 i lab 1
Cis336 week 1 i lab 1
 
Acc 460 final exam
Acc 460 final examAcc 460 final exam
Acc 460 final exam
 
Cis336 week 1 i lab 1
Cis336 week 1 i lab 1Cis336 week 1 i lab 1
Cis336 week 1 i lab 1
 
Cis336 week 1 i lab 1
Cis336 week 1 i lab 1Cis336 week 1 i lab 1
Cis336 week 1 i lab 1
 
Cis336 week 2 i lab 2
Cis336 week 2 i lab 2Cis336 week 2 i lab 2
Cis336 week 2 i lab 2
 
Cis336 week 1 i lab 1
Cis336 week 1 i lab 1Cis336 week 1 i lab 1
Cis336 week 1 i lab 1
 

Recently uploaded

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Cis336 week 6 i lab 6

  • 1. CIS 336 Week 6 iLab 6 Devry University Click this link to get the tutorial: http://homeworkfox.com/tutorials/general- questions/4156/cis-336-week-6-ilab-6-devry-university/ Lab 6 of 7: Oracle Single Row and Group Functions (28 points) Lab #6 will introduce the various aspects of the Single-Row and Group Functions available in the Oracle Database. Most functions can be used in either the SELECT statement or the WHERE clause, but more commonly are used in the SELECT. Chapters 5 and 6 cover most all of the normal processing you use in these functions. In some cases, you will be asked to used more than one function within a single SELECT statement. General Lab Information and Considerations This lab will utilize the same set of tables found in the script file (LeeBooks.SQL) that were used for Labs 4 and 5. Each query in the script file you will create must be numbered (use --1 comments for numbering) and in order. The SQL for the following exercises should be written using notepad and run in SQL*Plus. Read each problem carefully and follow the directions as stated. A Clean Script File: A script file is meant to be like a program. The file can be run every time the code needs to be executed without having to retype the code again each time. For this reason, it is important that there are no errors in the code inside the file. You can go back and forth between notepad and Oracle when creating your script file to check your queries and verify if they work or not. However, you do not want to create your final output file until after you have verified that everything in your script is correct by running it, in its entirety at least once and viewing the output. Once this has been done, you can create your final output file, with echo to create the document, you can turn in with your lab. Remember in using a spool session, you must type "SPOOL OFF" at the SQL> prompt after your script stops spooling to capture all of your data! Lab Do's and Don’t's * Do Not include the LEEBOOKS.SQL as part of your lab script. o Do use Notepad to write your query script file. * Do Not write your queries in Word. o Do test each query before moving on to the next. * Do Not include extra queries for a problem unless the problem explicitly asks for more than one query. o Do test your queries before creating your final output file. * Do Not turn in a script file that has queries with errors. o Do number each query using - -1 comment notation. * Do Not start your query on the same line as the comment. o Do remember to check your final output and script file for accuracy. * Do Not turn in your lab without first checking your output file to verify that it is correct. Things to keep in mind: If you are not sure of the table names in your user schema, you can use the following select statement to list them. SELECT * FROM TAB; If you want to know the name of the columns in a particular table you can use the following command to list them. DESC Making a script file containing a series of describe statements for each table and then spooling the output will give you a listing of all the tables with column names. Be sure to review and verify your final output when you are finished. Do Not assume anything. Write queries for each of the stated problems in the steps below that will return a result set of data to satisfy the requirements. When finished, your script file should have a total of 13 queries, and your resulting output file should
  • 2. show both the query and result set for each. Deliverables Submit for grading: 1. Your script file with the 13 queries in it. Be sure your name, course number, and lab number are in a comment area at the top of your file. 2. An output file created using SET ECHO ON showing both the SQL code and the results. 3. Both documents are to be zipped into a single file before submitting to the iLab Dropbox for Week 6 Week 6. L A B S T E P S STEP 1: Back to top Using the BOOK_CUSTOMER table and the NVL function, create a query that will return a list containing the customer number, first name, last name, and the characters ‘NOT REFERRED’ if the customer was not referred by another customer. Give the derived column an alias of REFERRED BY. Do not list any customers that were referred by another customer. STEP 2: Back to top Using the BOOKS table and the SUBSTR function, create a query that will return a list of book ISBN codes and the book title for all the computer books. Format the ISBN code to display as 9- 999-99999-9 (e.g., 1059831198 would display as 1-059-83119-8) STEP 3: Back to top Using the BOOKS table, create a query using the correct functions to return the category name, the total retail of all books per category with a column alias of "Total Retail", and the average retail of all the books per category with an alias of "Average Retail" for all categories with a total retail greater than $40.00. Format the total retail and average retail columns using the correct function to show dollars and cents with a dollar sign. STEP 4: Back to top Using the correct tables in your schema, create a query using either join operation you wish that will list the book title and number of authors for all books that have been written by more than one author. Give the title column an alias of "Book Title" and the column showing the number of authors an alias of "Number of Authors". STEP 5: Back to top Using the BOOK_AUTHOR and AUTHOR tables for the upper most query, create a sub query that will return the BOOKID, and the first and last name of the author(s) who have written the book(s) that have been purchased the most. To successfully accomplish this, you will need to first find out the maximum total number of copies (based on quantity) sold of a book (based on bookid) in the ORDER_ITEMS table. This will be done in the bottom most query. The return from this query will be used to compare against the BOOKID in the ORDER_ITEMS table that occurs an equal number of times in the middle query. The return of this query will then be used to compare to a BOOKID related to an Author in the tables of the top most query. (HINT: Be careful, you will need both GROUP BY and HAVING clauses for your solution.) STEP 6: Back to top Using the correct tables, create a sub query using either join operation you wish that will list the customer number, first and last name concatenated together, and city for all customers who have placed an order for the most expensive book (based on retail price). Give the combined customer names column and alias of "Customer Name". STEP 7: Back to top Using the ORDER_ITEMS table, create a query using the correct functions to return the item#, the total quantity of items ordered with an alias of "Total", the average quantity per order
  • 3. with an alias of "Average" (since averages are often in decimals, only show two decimal places), the minimum quantity ordered with an alias of "Minimum", and the maximum quantity ordered with an alias of "Maximum". Your output results set should have five columns and four rows of data. STEP 8: Back to top Using the BOOKS table, create a query using the DECODE function that will display the book title, the published date, and the publisher name (this is where the decode function comes in). Give the publisher name column an alias of "Publisher Name", and order the publisher names in descending order. The publisher names used should be the same as those in the PUBLISHER table. DO NOT join to the Publisher table for this query. STEP 9: Back to top Using the PUBLISHER table, create a query that will return a line of output like the one below for each record in the table. Be sure to use the correct functions in the SELECT statement, so that your output looks like the example below. The contact person for Printing Is Us Publishing is Tommie Seymour. Be sure to use the correct function to display the publisher name and publisher contact with only the first letter of each word capitalized. STEP 10: Back to top Using the correct tables, create a query using the JOIN ON method to display a listing of all customers who have purchased more than two books. List the customer’s last name, the customer’s city and state, and the number of books they have purchased. Give the number purchased column and alias of "Number Purchased". STEP 11: Back to top Using only the BOOK table for the upper most statement, create a sub query that will update the retail price of all books published by PRINTING IS US by five percent (retail * 1.05). Remember, all you have is the publisher "name". Use the sub query to find the publisher ID. To verify your update, provide a select statement on the BOOKS table before your update statement, and then a second select on the BOOKS table after the update. Once you have verified the results, you can issue a ROLLBACK statement to return the data to the original state. STEP 12: Back to top Using the BOOK_CUSTOMER table, write a sub query that will return the names of those customers who were referred by the same individual who referred Jorge Perez. Do not display Jorge Perez’s name in the returned results (Hint: you should only have two customers displayed and the exclusion for Jorge Perez must be associated with the upper query). STEP 13: Back to top Using the BOOKS table, create a query using the correct functions to return the category name, total number books per category with a column alias of "Category Total", and the total cost of all the books per category with an alias of "Cost". Format the cost column using the correct function to show dollars and cents with a dollar sign. This is the end of Lab #6 Back to top]HTML