Is the AVG(op.quantity) result correct. Your query does a GROUP BY product_id. I think you need a very similar query with AVG(op.quantity) and a GROUP BY category_id, so that the average will be calcualted by category.
Is the AVG(op.quantity) result correct. Your query does a GROUP BY product_id. I think you need a very similar query with AVG(op.quantity) and a GROUP BY category_id, so that the average will be calcualted by category.