JOIN dimension and fact tables with aggregation and LIMIT
Who are our biggest spenders? Pull the top 5 customers by total spend. I need their customer_id, first_name, last_name, and total amount spent. Exclude refunds.
Each hint you reveal reduces the XP you can earn. Try the query first.
JOIN `dim_customers` to `fact_purchases` on `customer_id`, then filter `WHERE p.amount > 0` to exclude refunds
GROUP BY customer_id, first_name, last_name and use `SUM(p.amount) AS total_spent`
Sort with `ORDER BY total_spent DESC LIMIT 5` to get the top 5 spenders