Questions Write SQL statements that will answer the following four questions based on the following tables. 1. Find suppliers (company name, country and city) whose country is Australia or whose city is Paris. 2. Compute the extended price for each order. Extended price is obtained by multiplying unit price by quantity (from Order Details table). Show order id, product name and extended price. Sort the results by product name in ascending order. 3. List products ids and product names of discontinued confection products that are still held in stock. (Confection products are those that have "Confections" as category name.) 4. Find the total quantity of each product ordered within each category. Display the category id, category name, product name and total quantity.     Hints: The MONTH(DateField) function can be used to evaluate criteria about the month portion of a date field. The FORMAT(DateField) function can be used to return the month names. The SELECT statement has several options that can be used to select a certain set of values from the resulting query. SELECT [ALL | DISTINCT | DISTINCTROW | [TOP n [PERCENT]]] FROM Table ALL Default - selects all records DISTINCT Omits records that contain duplicate data in  the selected fields. DISTINCTROW Omits data based on entire duplicate records,  not just duplicate fields. TOP n [Percent] Returns a certain number of records that fall  at the top or the bottom of a range specified  by an ORDER BY clause. Tables and fields: Categories Name Type Size 137 Page 2 of 3 pages CategoryID Number (Long) 4 CategoryName Text 15 Description Memo - Picture OLE Object - Products Name Type Size ProductID Number (Long) 4 ProductName Text 40 SupplierID Number (Long) 4 CategoryID Number (Long) 4 QuantityPerUnit Text 20 UnitPrice Currency 8 UnitsInStock Number (Integer) 2 UnitsOnOrder Number (Integer) 2 ReorderLevel Number (Integer) 2 Discontinued Yes/No 1 Suppliers Name Type Size SupplierID Number (Long) 4 CompanyName Text 40 ContactName Text 30 ContactTitle Text 30 Address Text 60 City Text 15 Region Text 15 PostalCode Text 10 Country Text 15 Phone Text 24 Fax Text 24 HomePage Hyperlink - Orders Name Type Size OrderID Number (Long) 4 CustomerID Text 5 EmployeeID Number (Long) 4 OrderDate Date/Time 8 RequiredDate Date/Time 8 ShippedDate Date/Time 8 ShipVia Number (Long) 4 Freight Currency 8 ShipName Text 40 ShipAdresss Text 60 ShipCity Text 15 ShipRegion Text 15 ShipPostalCode Text 10 ShipCountry Text 15 Order Details Name Type Size OrderID Number (Long) 4 ProductID Number (Long) 4 UnitPrice Currency 8 Quantity Number (Integer) 2 Discount Number (Single) 4 138 There is a one-to-many relationship between categories and products (that is, there can be many products belonging to a category). There are also one-to-many relationships between suppliers and products, orders and order details, products and order detail

Oracle 12c: SQL
3rd Edition
ISBN:9781305251038
Author:Joan Casteel
Publisher:Joan Casteel
Chapter12: Subqueries And Merge Statements
Section: Chapter Questions
Problem 19MC
icon
Related questions
Question

Questions
Write SQL statements that will answer the following four questions based on
the following tables.
1. Find suppliers (company name, country and city) whose country is
Australia or whose city is Paris.
2. Compute the extended price for each order. Extended price is obtained by
multiplying unit price by quantity (from Order Details table). Show order id,
product name and extended price. Sort the results by product name in
ascending order.
3. List products ids and product names of discontinued confection products
that are still held in stock. (Confection products are those that have
"Confections" as category name.)
4. Find the total quantity of each product ordered within each category.
Display the category id, category name, product name and total quantity.  

 

Hints:
The MONTH(DateField) function can be used to evaluate criteria about the month portion of a
date field.
The FORMAT(DateField) function can be used to return the month names.
The SELECT statement has several options that can be used to select a
certain set of values from the resulting query.
SELECT [ALL | DISTINCT | DISTINCTROW | [TOP n [PERCENT]]] FROM Table
ALL Default - selects all records
DISTINCT Omits records that contain duplicate data in
 the selected fields.
DISTINCTROW Omits data based on entire duplicate records,
 not just duplicate fields.
TOP n [Percent] Returns a certain number of records that fall
 at the top or the bottom of a range specified
 by an ORDER BY clause.
Tables and fields:
Categories
Name Type Size

137
Page 2 of 3 pages
CategoryID Number (Long) 4
CategoryName Text 15
Description Memo -
Picture OLE Object -
Products
Name Type Size

ProductID Number (Long) 4
ProductName Text 40
SupplierID Number (Long) 4
CategoryID Number (Long) 4
QuantityPerUnit Text 20
UnitPrice Currency 8
UnitsInStock Number (Integer) 2
UnitsOnOrder Number (Integer) 2
ReorderLevel Number (Integer) 2
Discontinued Yes/No 1
Suppliers
Name Type Size
SupplierID Number (Long) 4
CompanyName Text 40
ContactName Text 30
ContactTitle Text 30
Address Text 60
City Text 15
Region Text 15
PostalCode Text 10
Country Text 15
Phone Text 24
Fax Text 24
HomePage Hyperlink -
Orders
Name Type Size
OrderID Number (Long) 4
CustomerID Text 5
EmployeeID Number (Long) 4
OrderDate Date/Time 8
RequiredDate Date/Time 8
ShippedDate Date/Time 8
ShipVia Number (Long) 4
Freight Currency 8
ShipName Text 40
ShipAdresss Text 60
ShipCity Text 15
ShipRegion Text 15
ShipPostalCode Text 10
ShipCountry Text 15
Order Details
Name Type Size
OrderID Number (Long) 4
ProductID Number (Long) 4
UnitPrice Currency 8
Quantity Number (Integer) 2
Discount Number (Single) 4
138

There is a one-to-many relationship between categories and products (that is, there can be many
products belonging to a category). There are also one-to-many relationships between suppliers
and products, orders and order details, products and order detail

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
SQL Query
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Oracle 12c: SQL
Oracle 12c: SQL
Computer Science
ISBN:
9781305251038
Author:
Joan Casteel
Publisher:
Cengage Learning
A Guide to SQL
A Guide to SQL
Computer Science
ISBN:
9781111527273
Author:
Philip J. Pratt
Publisher:
Course Technology Ptr
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781305627482
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781285196145
Author:
Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos Coronel
Publisher:
Cengage Learning
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning