How do I sort by country and then by value (DESC) in SQL?
SELECT country, quantity * unit_price AS line_total
FROM data
ORDER BY country DESC, line_total DESC;
Run this query in QueryLocal →
Multi-column `ORDER BY` sorts first by country (DESC), and only breaks ties on that column using `line_total DESC` as the second key — the same tie-breaking logic as sorting a spreadsheet by two columns at once.
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).