Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am trying to modify the following query so the solution only counts and totals line items that have an item_price value thats greater than

I am trying to modify the following query so the solution only counts and totals line items that have an item_price value thats greater than 400. But not sure if I should be using HAVING or WHERE clause.

SELECT email_address, COUNT(DISTINCT oi.order_id) AS num_orders, SUM((item_price - discount_amount) * quantity) AS total_amount

FROM customers c JOIN orders o

ON c.customer_id = o.customer_id

JOIN order_items oi

ON oi.order_id = o.order_id

GROUP BY email_address

HAVING COUNT(oi.order_id) > 1

ORDER BY SUM(item_price) DESC;

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

Nested Relations And Complex Objects In Databases Lncs 361

Authors: Serge Abiteboul ,Patrick C. Fischer ,Hans-Jorg Schek

1st Edition

3540511717, 978-3540511717

More Books

Students also viewed these Databases questions

Question

11. Are your speaking notes helpful and effective?

Answered: 1 week ago

Question

The Goals of Informative Speaking Topics for Informative

Answered: 1 week ago