How do I sum a numeric column across all rows?
SELECT SUM(quantity * unit_price) AS total_revenue FROM data;
Run this query in QueryLocal →
`SUM()` adds up a numeric expression across every row that matches the query. Here `quantity * unit_price` computes each order's line total first, and `SUM()` totals those line totals into a single grand total — a one-line replacement for a spreadsheet formula dragged down a column and summed at the bottom.
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).