>_QueryLocalCSV & JSON tools that run in your browser

How do I count rows per country with SQL GROUP BY?

SELECT country, COUNT(*) AS orders
FROM data
GROUP BY country
ORDER BY orders DESC;

Run this query on the demo dataset →

COUNT(*) inside a GROUP BY country query counts how many rows fall into each country, rather than counting the whole table at once. Ordering by that count descending surfaces the most frequent country first.

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 Count rows in a CSV: your file becomes the table data, and you can paste this query with your own column names.

Related recipes