Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question: - - Premium customers are those customers who have placed orders with order amounts greater than the average order amount. For each customer, find

Question:
-- Premium customers are those customers who have placed orders with order amounts greater than the average order amount. For each customer, find the first and last names, and the order amount for all orders that exceeded the average order amount?
SELECT customer.first_name, customer.last_name, sum(order_line.quantity_sold * product.product_price) as Ordertotal
FROM customer, order_line,product, orders
INNER JOIN orders ON orders.customer_Id = customer.customer_id
INNER JOIN (
SELECT order_id
FROM order_line
INNER JOIN product ON product.product_id = order_line.product_id
GROUP BY order_id
) AS orders ON orders.order_id = order_line.order_id
WHERE order_line.ordertotal >(
SELECT AVG(SUM(quantity_sold * product_price))
FROM order_line, product
INNER JOIN product ON order_line.product_id = product.product_id
GROUP BY order_line.order_id
);

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

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions