>_ QueryLocal All recipes
SQL recipe

How do I compute the average unit price per country in SQL?

SELECT country, AVG(unit_price) AS avg_price
FROM data
GROUP BY country
ORDER BY avg_price DESC;
Run this query in QueryLocal →

`AVG(unit_price)` computed after `GROUP BY country` gives the mean unit price within each country, not across the whole table. This is the aggregate-function-plus-GROUP-BY pattern applied to a different grouping column and a different metric.

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).