SELECT country, category, quantity * unit_price AS line_total
FROM data
ORDER BY country ASC, line_total DESC;
Run this query on the demo dataset →
ORDER BY accepts a comma-separated list of columns, each with its own direction (ASC or DESC, ascending by default). Rows are sorted by the first column, and only when two rows tie on that column does the second column break the tie — here, alphabetically by country, then by line total within each country.
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.