 <p>The answer is: You cannot use an alias name in GROUP BY.</p> <p>So:</p> <pre><code>GROUP BY (SELECT customer_address.post_code ...); </code></pre> <p>Or:</p> <pre><code>select postcode, sum(order_no) from ( SELECT (SELECT customer_address.post_code FROM customer_address WHERE customer_address.address_type = 0 AND customer_address.customer_no = orders.customer_no) postcode, orders.order_no FROM orders, customer_address WHERE orders.delivery_date = '27-MAY-15' ) GROUP BY postcode; </code></pre> <p>EDIT:</p> <p>However, your query seems wrong. Why do you cross-join orders and customer_address? By mistake I guess. Use explicit joins (<code>INNER JOIN customer_address ON ...</code>), when using joins to avoid such errors. But here I guess you'd just have to remove <code>, customer_address</code>.</p> <p>Then why do you add order numbers? That doesn't seem to make sense.</p>