Code24Lab
Read first

The SQL

-- Query 1
SELECT o.order_id, c.name, o.amount
FROM orders AS o
INNER JOIN customers AS c
  ON c.customer_id = o.customer_id
WHERE c.city = 'Basel';

-- Query 2
SELECT c.city, SUM(o.amount) AS revenue
FROM orders AS o
JOIN customers AS c USING (customer_id)
WHERE o.status <> 'Cancelled'
GROUP BY c.city
ORDER BY revenue DESC;
Give every table a short alias and prefix every column with it (o.amount, c.city). With two tables in the query, an unqualified column such as customer_id would be ambiguous (error 1052).
Loading the lab…