The code for OrderTotalWithHaving.sql is: SELECT ordernumber, COUNT(productCode) AS productsCount, SUM(quantityOrdered) AS itemsCount, SUM(priceeach*quantityOrdered) AS total FROM orderdetails GROUP BY ordernumber HAVING total > 1000;