SlideShare una empresa de Scribd logo
1 de 4
SOLUTIONJUG.COM

CIS/336 iLab 5 of 7 - SQL Course

CLICK HERE TO GET THE SOLUTION !!!!!!!!




Lab 5 of 7: Retreiving data from Multiple Tables (28 points)
LABOVERVIEW
Scenario/Summary

Lab 5 deals with writing queries using multiple tables as covered in the reading and lecture material
this week. In some cases, you will be given the option to write a query using either the
TRADITIONAL method of joining tables or using the JOIN key word. In some cases, you will be
asked to use a specific approach. Using the incorrect process when the process is specified will
result in points being taken off for that problem.

The SELECT statement is the primary means of extracting data from database tables, and allows
you to determine exactly which data you want to extract by means of different comparison
operators used in the WHERE clause. This includes the use of specific "wild card" characters which
allow you to search for character or number patterns within the data. You can also perform
mathematical expressions within the SELECT statement to create derived output. The ORDER BY
clause allows you to sort the output data in either ascending (the default) or descending order. Lab
#5 will explore all of these applications of the SELECT statement.
General Lab Information and Considerations
This lab will utilize a set of tables found in the script file (LeeBooks.sql) found in the Doc Sharing
area of the website. If you have not yet downloaded this file from Doc Sharing then do so now.
Once you have downloaded the script file, import and run the script in SQL*Plus.
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.




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, but 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 on to create the document you can turn in with your
lab. If using a Spool Session, be sure to type "SPOOL OFF" AT THE SQL> after your Script Stops
Spooling!

Lab Do's and Don’t's
Do Not include the LEEBOOKS.SQL as part of your lab script.

Do use Notepad to write your query script file.

Do Not write your queries in Word.

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.

Do test your queries before creating your final output file.

Do Not turn in a script file that has queries with errors.

Do number each query using --1 comment notation.

Do Not start your query on the same line as the comment.

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:
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. Submitting ONLY your spooled output will result in a 10-point
deduction.

An output file created using SET ECHO ON showing both the SQL code and the results.

Both documents must be zipped into a single file before submitting to the iLab Dropbox for Week 5.

LABSTEPS

STEP 1:
Using the BOOKS and PUBLISHER tables, create a query using the traditional join method that will
return a list containing the book title, publisher contact person, and publisher phone number for all
publishers whose publisher name starts with an „R‟.
STEP 2:
Using the DUAL table, create a query that will return the day of the week, hour, minutes, and
seconds of the current date setting on a computer. The day should be in all upper case.
STEP 3:
Using the BOOK_CUSTOMER and BOOK_ORDER tables, create a query using the NATURAL JOIN
method that will return a list containing the customer first name and last name and the order
number for all orders that have been shipped. Give the customer name column an alias of
"Customer Name" and order the output by the customer number in the BOOK_ORDER table in
ascending order.
STEP 4:
Using the BOOK_ORDER table, create a query that will return the order number, order date,
shipping address, city, state, and zip code for all orders going to Atlanta or Austin. Format the order
date to display as Month DD, YYYY and give the column an alias of "Date Ordered". Be sure the
month begins with a capital letter.

STEP 5:
Using the BOOK_ORDER table, create a query using the correct function to return the order number,
the date ordered, the date shipped, and a column representing the number of months between the
two dates for all columns where a date shipped exists. Format the number returned from the
function to display only two decimals, and give the column an alias of "Months Between".

NOTE: Be sure that all of the numbers in the fourth column are positive numbers.
STEP 6:
Using the correct tables in your schema, create a query using either join operation that will list the
title of each book and author name(s). Give the title column an alias of "Book Title". Sort the results
by title and then by author last name.
STEP 7:
Using the BOOKS table, create a query that will return the book title, cost, and retail price for all
books with a title starting with the letter „H‟. Use the correct conversion function to format the cost
and retail columns to show dollars and cents with a dollar sign (e.g., a price of $25 would display
$25.00 in the result set).
STEP 8:
Using the BOOK_ORDER, ORDER_ITEMS, and BOOKS tables, create a query using an OUTER JOIN
operation that will list the book title, order date, and order number for all books in the BOOKS table.
Order your output in descending order by ORDER_ITEMS.BOOKID. There are three books that have
never been ordered which should show up at the top of your listing.
STEP 9:
Using the correct tables, create a query using the traditional join operation that will list the customer
first and last name, book title, and order date (formatted as MM/DD/YYYY with an alias of “Order
Date”) for all the customers who have purchased books published by 'PRINTING IS US'.
STEP 10:
Using the BOOKS and ORDER_ITEMS table, write a query using the correct Relational Set Operator
that will show all of the Book IDs in the BOOKS table that have not been ordered.



STEP 11:
Using the BOOK_CUSTOMER, BOOK_ORDER, ORDER_ITEMS, and BOOKS tables, create a query
using traditional join conditions based on comparisons between primary and foreign keys that will
list the customer number, first and last name, and book title. Limit your listing to only those books in
the „FITNESS‟ category.
STEP 12:
Using the BOOKS, ORDER_ITEMS, and BOOK_ORDER tables, create a query that will list the title,
retail, quantity, and order date for all books ordered after April 30, 2009.
STEP 13:
Using the correct tables, create a query using either join operation you wish that will list the order
id, order date, quantity ordered, and retail price for every book that has been ordered. Format the
date as MM/DD/YYYY with an alias of “Order Date” and format the retail price column using the
correct function to show dollars and cents with a dollar sign ( $ ) and a column alias of “Retail”.

This is the end of lab #5

CLICK HERE TO GET THE SOLUTION !!!!!!!!

Más contenido relacionado

Último

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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
🐬 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
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Último (20)

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...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
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...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

Destacado

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Destacado (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

Cis 336 ilab 5 of 7

  • 1. SOLUTIONJUG.COM CIS/336 iLab 5 of 7 - SQL Course CLICK HERE TO GET THE SOLUTION !!!!!!!! Lab 5 of 7: Retreiving data from Multiple Tables (28 points) LABOVERVIEW Scenario/Summary Lab 5 deals with writing queries using multiple tables as covered in the reading and lecture material this week. In some cases, you will be given the option to write a query using either the TRADITIONAL method of joining tables or using the JOIN key word. In some cases, you will be asked to use a specific approach. Using the incorrect process when the process is specified will result in points being taken off for that problem. The SELECT statement is the primary means of extracting data from database tables, and allows you to determine exactly which data you want to extract by means of different comparison operators used in the WHERE clause. This includes the use of specific "wild card" characters which allow you to search for character or number patterns within the data. You can also perform mathematical expressions within the SELECT statement to create derived output. The ORDER BY clause allows you to sort the output data in either ascending (the default) or descending order. Lab #5 will explore all of these applications of the SELECT statement. General Lab Information and Considerations This lab will utilize a set of tables found in the script file (LeeBooks.sql) found in the Doc Sharing area of the website. If you have not yet downloaded this file from Doc Sharing then do so now. Once you have downloaded the script file, import and run the script in SQL*Plus. 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. 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, but 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 on to create the document you can turn in with your
  • 2. lab. If using a Spool Session, be sure to type "SPOOL OFF" AT THE SQL> after your Script Stops Spooling! Lab Do's and Don’t's Do Not include the LEEBOOKS.SQL as part of your lab script. Do use Notepad to write your query script file. Do Not write your queries in Word. 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. Do test your queries before creating your final output file. Do Not turn in a script file that has queries with errors. Do number each query using --1 comment notation. Do Not start your query on the same line as the comment. 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.
  • 3. Deliverables Submit for grading: 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. Submitting ONLY your spooled output will result in a 10-point deduction. An output file created using SET ECHO ON showing both the SQL code and the results. Both documents must be zipped into a single file before submitting to the iLab Dropbox for Week 5. LABSTEPS STEP 1: Using the BOOKS and PUBLISHER tables, create a query using the traditional join method that will return a list containing the book title, publisher contact person, and publisher phone number for all publishers whose publisher name starts with an „R‟. STEP 2: Using the DUAL table, create a query that will return the day of the week, hour, minutes, and seconds of the current date setting on a computer. The day should be in all upper case. STEP 3: Using the BOOK_CUSTOMER and BOOK_ORDER tables, create a query using the NATURAL JOIN method that will return a list containing the customer first name and last name and the order number for all orders that have been shipped. Give the customer name column an alias of "Customer Name" and order the output by the customer number in the BOOK_ORDER table in ascending order. STEP 4: Using the BOOK_ORDER table, create a query that will return the order number, order date, shipping address, city, state, and zip code for all orders going to Atlanta or Austin. Format the order date to display as Month DD, YYYY and give the column an alias of "Date Ordered". Be sure the month begins with a capital letter. STEP 5: Using the BOOK_ORDER table, create a query using the correct function to return the order number, the date ordered, the date shipped, and a column representing the number of months between the two dates for all columns where a date shipped exists. Format the number returned from the function to display only two decimals, and give the column an alias of "Months Between". NOTE: Be sure that all of the numbers in the fourth column are positive numbers.
  • 4. STEP 6: Using the correct tables in your schema, create a query using either join operation that will list the title of each book and author name(s). Give the title column an alias of "Book Title". Sort the results by title and then by author last name. STEP 7: Using the BOOKS table, create a query that will return the book title, cost, and retail price for all books with a title starting with the letter „H‟. Use the correct conversion function to format the cost and retail columns to show dollars and cents with a dollar sign (e.g., a price of $25 would display $25.00 in the result set). STEP 8: Using the BOOK_ORDER, ORDER_ITEMS, and BOOKS tables, create a query using an OUTER JOIN operation that will list the book title, order date, and order number for all books in the BOOKS table. Order your output in descending order by ORDER_ITEMS.BOOKID. There are three books that have never been ordered which should show up at the top of your listing. STEP 9: Using the correct tables, create a query using the traditional join operation that will list the customer first and last name, book title, and order date (formatted as MM/DD/YYYY with an alias of “Order Date”) for all the customers who have purchased books published by 'PRINTING IS US'. STEP 10: Using the BOOKS and ORDER_ITEMS table, write a query using the correct Relational Set Operator that will show all of the Book IDs in the BOOKS table that have not been ordered. STEP 11: Using the BOOK_CUSTOMER, BOOK_ORDER, ORDER_ITEMS, and BOOKS tables, create a query using traditional join conditions based on comparisons between primary and foreign keys that will list the customer number, first and last name, and book title. Limit your listing to only those books in the „FITNESS‟ category. STEP 12: Using the BOOKS, ORDER_ITEMS, and BOOK_ORDER tables, create a query that will list the title, retail, quantity, and order date for all books ordered after April 30, 2009. STEP 13: Using the correct tables, create a query using either join operation you wish that will list the order id, order date, quantity ordered, and retail price for every book that has been ordered. Format the date as MM/DD/YYYY with an alias of “Order Date” and format the retail price column using the correct function to show dollars and cents with a dollar sign ( $ ) and a column alias of “Retail”. This is the end of lab #5 CLICK HERE TO GET THE SOLUTION !!!!!!!!