R
Richard Horne
Hi guys, I have a query containing the following fields:
OrderNumber, ItemNumber, QuantityOrdered and QuantityDelivered
QuantityDelivered is the SUM of all Deliveries against each Item in an order.
I'm trying to generate another field called QuantityRemaining which is equal
to:
QuantityOrdered-SUM(QuantityDelivered)
But this does not seem to work, what should I put as my criteria for
QuantityRemaining?
My SQL Code is:
SELECT Orders.OrderNumber, Order_Details.[Item Number],
Order_Details.Quantity, Sum(Delivery_Details.QtyDelivered) AS
SumOfQtyDelivered, [Remaining] AS Expr1
FROM Delivery_Details INNER JOIN ((Orders INNER JOIN Order_Details ON
Orders.OrderNumber = Order_Details.OrderNumber) INNER JOIN Deliveries ON
Orders.OrderNumber = Deliveries.OrderNumber) ON
(Delivery_Details.DeliveryNoteID = Deliveries.DeliveryNoteID) AND
(Delivery_Details.ItemNumber = Order_Details.[Item Number])
GROUP BY Orders.OrderNumber, Order_Details.[Item Number],
Order_Details.Quantity, [Remaining]
HAVING ((([Remaining])=("Quantity")-Sum("QtyDelivered")))
ORDER BY Orders.OrderNumber, Order_Details.[Item Number];
OrderNumber, ItemNumber, QuantityOrdered and QuantityDelivered
QuantityDelivered is the SUM of all Deliveries against each Item in an order.
I'm trying to generate another field called QuantityRemaining which is equal
to:
QuantityOrdered-SUM(QuantityDelivered)
But this does not seem to work, what should I put as my criteria for
QuantityRemaining?
My SQL Code is:
SELECT Orders.OrderNumber, Order_Details.[Item Number],
Order_Details.Quantity, Sum(Delivery_Details.QtyDelivered) AS
SumOfQtyDelivered, [Remaining] AS Expr1
FROM Delivery_Details INNER JOIN ((Orders INNER JOIN Order_Details ON
Orders.OrderNumber = Order_Details.OrderNumber) INNER JOIN Deliveries ON
Orders.OrderNumber = Deliveries.OrderNumber) ON
(Delivery_Details.DeliveryNoteID = Deliveries.DeliveryNoteID) AND
(Delivery_Details.ItemNumber = Order_Details.[Item Number])
GROUP BY Orders.OrderNumber, Order_Details.[Item Number],
Order_Details.Quantity, [Remaining]
HAVING ((([Remaining])=("Quantity")-Sum("QtyDelivered")))
ORDER BY Orders.OrderNumber, Order_Details.[Item Number];