I have problem with the following query:
SELECT product.prod_id, product.title, product.thumb, product.price
FROM product, order_detail
WHERE product.prod_id=order_detail.product_id
GROUP BY order_detail.product_id
ORDER BY SUM(order_detail.quantity);
On my computer (MySQL 5.0.51a) it works fine.
But on my server (MySQL 4.1.22) I get the msg:"invalid use of group function". Only if I remove the "ORDER BY SUM(order_detail.quantity)" it works.
Can you help me?
I fixed it:
SELECT product.prod_id, product.title, product.thumb, product.price, SUM(order_detail.quantity) AS quantity_sum
FROM product, order_detail
WHERE product.prod_id=order_detail.product_id
GROUP BY order_detail.product_id
ORDER BY quantity_sum;
SELECT product.prod_id, product.title, product.thumb, product.price
FROM product, order_detail
WHERE product.prod_id=order_detail.product_id
GROUP BY order_detail.product_id
ORDER BY SUM(order_detail.quantity);
On my computer (MySQL 5.0.51a) it works fine.
But on my server (MySQL 4.1.22) I get the msg:"invalid use of group function". Only if I remove the "ORDER BY SUM(order_detail.quantity)" it works.
Can you help me?
I fixed it:
SELECT product.prod_id, product.title, product.thumb, product.price, SUM(order_detail.quantity) AS quantity_sum
FROM product, order_detail
WHERE product.prod_id=order_detail.product_id
GROUP BY order_detail.product_id
ORDER BY quantity_sum;
Last edited:






