Hey guys,
I keep getting a "A.order_date" unknown error with the following query:
I'll try as best I can to describe what I believe's going on here!
I've got tblOrder - with order info
tblOrder_Item - with item_id, order_id, aswell as item_name and quantity
tblItem - with item information
This query is used to pull information mainly from the tblOrder_Item table, but it also pulls the part number from tblItem.
The subquery is used to display how many of this item are already allocated to orders - so it sums item_qty.
But I want to change it so that instead of reading "allocated_stock", it will be like it's selecting "pre-allocated_stock". By that, I mean that stock should be allocated to orders on a first come first served basis. So that if an order contains an item which we only have 1 of in stock, the next order that comes in will see that one has been pre allocated. But the first order would show zero as pre-allocated because it's the first order of this type.
My SQL knowledge said to use the tblOrder.order_date < A.order_date, but that seems to be throwing this error!
Any assistance, as always, greatly appreciated.
I keep getting a "A.order_date" unknown error with the following query:
Code:
SELECT tblOrder_Item.orderitem_id, tblOrder_Item.item_id, tblOrder_Item.order_id, qryAllocatedStock.allocated_stock, tblOrder_Item.item_qty, tblItem.item_shelfStock, tblOrder_Item.item_name, tblItem.item_partno, tblOrder_Item.item_price, A.order_date
FROM
tblOrder A,
((tblOrder_Item INNER JOIN tblItem ON tblOrder_Item.item_id=tblItem.item_id) INNER JOIN (
SELECT SUM(tblOrder_Item.item_qty) AS allocated_stock, tblOrder_Item.item_id FROM tblOrder_Item, tblOrder WHERE (((tblOrder.order_id)=tblOrder_Item.order_id) And ((tblOrder.order_status)<>'dispatched')) Or (((tblOrder.order_status)<>'processing')) Or (((tblOrder.order_status)<>'printed')) And (tblOrder.order_date < A.order_date) GROUP BY tblOrder_Item.item_id)
AS qryAllocatedStock ON tblItem.item_id=qryAllocatedStock.item_id)
WHERE A.order_id = tblOrder_Item.order_id;
I'll try as best I can to describe what I believe's going on here!
I've got tblOrder - with order info
tblOrder_Item - with item_id, order_id, aswell as item_name and quantity
tblItem - with item information
This query is used to pull information mainly from the tblOrder_Item table, but it also pulls the part number from tblItem.
The subquery is used to display how many of this item are already allocated to orders - so it sums item_qty.
But I want to change it so that instead of reading "allocated_stock", it will be like it's selecting "pre-allocated_stock". By that, I mean that stock should be allocated to orders on a first come first served basis. So that if an order contains an item which we only have 1 of in stock, the next order that comes in will see that one has been pre allocated. But the first order would show zero as pre-allocated because it's the first order of this type.
My SQL knowledge said to use the tblOrder.order_date < A.order_date, but that seems to be throwing this error!
Any assistance, as always, greatly appreciated.