Selecting Groups

The HAVING condition is a 'condition to list' applied to groups. For example:

SELECT order_number FROM order_line
GROUP BY order_number
HAVING SUM(quantity)=5;

prints all order numbers for which at least five items have been ordered.