The code for OrderTotadForYear_with_HAVING.sql is: SELECT YEAR(orderDate) AS year, SUM(quantityOrdered * priceEach) AS total FROM orders INNER JOIN orderdetails USING (orderNumber) WHERE status = 'Shipped' #AND YEAR(orderDate) > 2003 # Can be used instead of HAVING, but the alias name cannot be used here. GROUP BY year HAVING year > 2003; #HAVING can use the alias and is therefore simpler and more clear.