Learn to summarize data with aggregate functions and GROUP BY. Transform thousands of rows into meaningful totals, averages, and counts — the foundation of every business report.
Start with the simplest aggregate: counting how many rows exist in a table.
SELECT COUNT(*) AS total_customers FROM customers;SELECT COUNT(*) AS total_orders FROM orders;SELECT COUNT(*) AS total_products FROM products;COUNT(*) counts every row in the result set, including rows with NULL values. The AS keyword gives the output column a readable name (an alias). Aggregate functions collapse many rows into a single summary row.
You should see one row per query with the total count. For example, total_customers might show 50, total_orders might show 200, depending on your seed data.