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

Instruction

Now, let's analyze our e-store's "good customers." Each business will use its own definition of a good customer that is based on their business model. In our e-store, we'll define a "good customer" as a customer whose average order value is above the general average order value for all customers. Analyzing such customers may help us understand what makes customers spend more. This, in turn, can help us decide which marketing campaigns we should focus on.

First, we need to see the average order value for each individual customer:

SELECT
  C.CustomerID,
  AVG(TotalAmount) AS AvgOrderValue
FROM Customers C
JOIN Orders O
  ON C.CustomerID = O.CustomerID
GROUP BY C.CustomerID
ORDER BY AVG(TotalAmount);

The query is quite straightforward: we join the tables Customers and Orders so that we can calculate AVG(TotalAmount) and get some additional information about the customer.

Exercise

Run the query from the template and analyze the results. What do you think about them? Look at the differences between customers. Are their average values similar or completely different? Why do you think this is?

Stuck? Here's a hint!