Using the customer_nodes and regions tables, calculate how many distinct customers are assigned to each region.
Show the columns region_name and total_customers.
Order by total_customers DESC, region_name ASC.
Hints
-
Hint 1
Start from customer_nodes and JOIN with regions using region_id.
You need the region name, not just the id.
-
Hint 2
A customer can appear multiple times.
For this reason, it is better to use COUNT(DISTINCT customer_id) and then GROUP BY region_name.