I'm the reports guy, so I struggle with SQL a bit.
Here's my jam: For a particular customer, for all their orders, get the total quantity of each item
they buy, and order big to small. (So we know what they buy most of.)
Here' s what I have, but each order is separate. The ORDER BY 3 DESC works, but only within separate orders, rather than 1 row for each item for all orders.
Thanks for any help.
SELECT items.itemcode, items.quantity,
( Sum( items.quantity) ) AS CC,
customers.custID,
orders.orderID
FROM customers, orders, items
WHERE
customers.custID = orders.custID
AND orders.orderID = items.orderID
AND customers.custID =
CID
GROUP BY orders.orderID, items.quantity, items.pricequote, items.itemcode, customers.custID
ORDER BY 3 DESC;
-- eom ---
Here's my jam: For a particular customer, for all their orders, get the total quantity of each item
they buy, and order big to small. (So we know what they buy most of.)
Here' s what I have, but each order is separate. The ORDER BY 3 DESC works, but only within separate orders, rather than 1 row for each item for all orders.
Thanks for any help.
SELECT items.itemcode, items.quantity,
( Sum( items.quantity) ) AS CC,
customers.custID,
orders.orderID
FROM customers, orders, items
WHERE
customers.custID = orders.custID
AND orders.orderID = items.orderID
AND customers.custID =
GROUP BY orders.orderID, items.quantity, items.pricequote, items.itemcode, customers.custID
ORDER BY 3 DESC;
-- eom ---