Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Chapter 6: How to Code Summary Queries Write a SELECT statement that returns one row for each customer that has orders with these columns: The

Chapter 6: How to Code Summary Queries

  1. Write a SELECT statement that returns one row for each customer that has orders with these columns:

The email_address column from the Customers table

The sum of the item price in the Order_Items table multiplied by the quantity in the Order_Items table

The sum of the discount amount column in the Order_Items table multiplied by the quantity in the Order_Items table

Sort the result set in descending sequence by the item price total for each customer.

  1. Write a SELECT statement that returns one row for each customer that has orders with these columns:

The email_address column from the Customers table

A count of the number of orders

The total amount for each order (Hint: First, subtract the discount amount from the price. Then, multiply by the quantity.)

Return only those rows where the customer has more than 1 order.

Sort the result set in descending sequence by the sum of the line item amounts.

  1. Modify the solution to exercise 2 so it only counts and totals line items that have an item_price value thats greater than 200.

Chapter 7: How to Code Subqueries

  1. Write a SELECT statement that returns three columns: email_address, order_id, and the order total for each customer. To do this, you can group the result set by the email_address and order_id columns. In addition, you must calculate the order total from the columns in the Order_Items table.

Write a second SELECT statement that uses the first SELECT statement in its FROM clause. The main query should return two columns: the customers email address and the largest order for that customer. To do this, you can group the result set by the email_address. Sort the result set by the largest order in descending sequence.

  1. Write a SELECT statement that returns the name and discount percent of each product that has a unique discount percent. In other words, dont include products that have the same discount percent as another product.

Sort the result set by the product_name column.

  1. Use a correlated subquery to return one row per customer, representing the customers oldest order (the one with the earliest date). Each row should include these three columns: email_address, order_id, and order_date.

Sort the result set by the order_date and order_id columns.

***Using Mysql, my_guitar_shop

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions

Question

How was their resistance overcome?

Answered: 1 week ago

Question

3. What strategies might you use?

Answered: 1 week ago