Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Customer activity
Finding good customers
Summary

Instruction

Great! Now that we know the general average order value per customer (1636.622), we can use the value of 1636 to find good customers. Look at the query below:

SELECT
  c.customer_id,
  AVG(total_amount) AS avg_order_value
FROM customers c
JOIN orders o
  ON c.customer_id = o.customer_id
GROUP BY c.customer_id
HAVING AVG(total_amount) > 1636;

In the query, we simply showed each customer with their average order value. This time, however, we used a HAVING clause with the average value we calculated earlier. This will ensure that only customers above that threshold are included in the results.

Exercise

The average order value per customer in France is 1564.853 . Now, for each French customer with an average order value above that, show the following columns: customer_id, full_name, and avg_order_value. Order the results by average order value, in descending order.

Stuck? Here's a hint!

Use the WHERE clause for filtering French customers, and the HAVING clause for comparing the average to 1564.853.