SELECT category, AVG(unit_price) AS avg_price
FROM data
GROUP BY category
ORDER BY avg_price DESC;
Run this query on the demo dataset →
AVG() is an aggregate function just like SUM() or COUNT() — combined with GROUP BY category, it computes the mean unit_price separately for each category instead of one overall average. Use this whenever the question is 'what's typical within each group', not 'what's typical overall'.
A table named data with columns: order_id (integer), customer (text), country (text), category (text), quantity (integer), unit_price (real), order_date (text, YYYY-MM-DD).
Want to run it on your own file? Open it with Query CSV with SQL: your file becomes the table data, and you can paste this query with your own column names.