Applying a JOIN
sounds pretty easy
SELECT article1, article2, size, order_date, SUM(quantity)
FROM orders
INNER JOIN customers ON orders.order_no = customers.order_no
WHERE customers.customer_no = '1027'
GROUP BY article1, article2, size, order_date, SUM(quantity)
You should note that nested SELECT
statements in a WHERE
clause almost always lead to bad performance.
Also that kind of unnormalized data model looks weird, but there may be good reasons why to keep order_no
and customer_no
pairs in a single association table. May be its just bad naming, something like customers_orders
might probably have been a better choice.