The inner query executes for every product line because the product line is changed for every row. Hence, the average buy price will also change.
In this tutorial, we have shown you how to use MySQL subquery and correlated subquery to write more complex queries.