The code for orderTotalByStatus.sql is: SELECT status, SUM(quantityOrdered * priceEach) AS amount FROM orders INNER JOIN orderdetails USING (orderNumber) GROUP BY status ORDER BY status;