Question: Using MYSQL 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

Using MYSQL

  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.

*tables

SELECT email_address FROM `my_guitar_shop`.`administrators`; SELECT order_id FROM `my_guitar_shop`.`orders`; SELECT `orders`.`order_id`, `orders`.`customer_id`, `orders`.`order_date`, `orders`.`ship_amount`, `orders`.`tax_amount`, `orders`.`ship_date`, `orders`.`ship_address_id`, `orders`.`card_type`, `orders`.`card_number`, `orders`.`card_expires`, `orders`.`billing_address_id` FROM `my_guitar_shop`.`orders`

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!