Real questions span multiple tables. JOINs combine them; aggregation summarises the results.
SQL JOINs & Aggregation
Combining tables and summarising data.
Tap or hover a part to learn more.
Only matches.
Returns only rows that have a match in both tables. Use it when you want records that exist on both sides — e.g. customers who have placed orders.
Check your understanding
1. Which JOIN returns all left-table rows plus matches?
2. What filters groups after aggregation?
Keep learning
JOIN types
- INNER JOIN — only rows with a match in both tables.
- LEFT JOIN — all rows from the left table, plus matches (NULLs where none) — great for "customers with no orders".
- RIGHT / FULL JOIN — the mirror and the union of both.
Aggregation
SELECT customer_id, COUNT(*), SUM(total) FROM orders GROUP BY customer_id; — GROUP BY buckets rows and functions (COUNT, SUM, AVG, MIN, MAX) summarise each bucket; HAVING filters the groups. JOINs rely on keys.
