Code24Lab

You are not signed in — the lab works, but your progress is not saved. Sign up

Lesson 1 of 20 is free. Unlock all 20 hands-on labs, the final exam and your certificate.

Buy course — CHF 19.90
Read first

The SQL

SELECT o.order_id, c.name, o.amount
FROM orders AS o
INNER JOIN customers AS c
  ON c.customer_id = o.customer_id;

SELECT c.customer_id, c.name,
       SUM(o.amount) AS revenue
FROM orders AS o
JOIN customers AS c
  ON c.customer_id = o.customer_id
GROUP BY c.customer_id, c.name;
Write the join condition as `c.customer_id = o.customer_id` with aliases on both sides. A join without an ON condition pairs every row with every row.
Loading the lab…