WhiteHatMarine
Programmer
I have a tricky query I cannot seem to come up with a good solution for. The first query functions. Second needs works. I would like to make this a single query, need help with that. The WHERE statement in Query2, not sure how to handle this as well. Query2 should be the result set. Code being executed in ColdFusion not native VFP.
Query1
SELECT WorkOrderHeader.wono , WorkOrderDetail.partno , SUM(WorkOrderDetail.qtyaloc) AS MatAllocated, MIN(WorkOrderHeader.reqdte) AS MinReqDate
FROM WorkOrderHeader INNER JOIN WorkOrderDetail ON WorkOrderHeader.wono = WorkOrderDetail.wono
GROUP BY WorkOrderDetail.partno
WHERE WorkOrderHeader.status < 0;
Query2
SELECT InvItem.item, InvLoc.lonhand, Query1.MatAllocated, Query1.MinReqDate
FROM InvItem INNER JOIN InvLoc ON InvItem.item = InvLoc.item INNER JOIN Query1 ON InvItem.item = Query1.partno
WHERE [InvItem.ionhand]-[Query1.MatAllocated]-[InvLoc.orderpt]+[InvLoc.lonordr]) <= 0;
Thanks!
Adrian
Query1
SELECT WorkOrderHeader.wono , WorkOrderDetail.partno , SUM(WorkOrderDetail.qtyaloc) AS MatAllocated, MIN(WorkOrderHeader.reqdte) AS MinReqDate
FROM WorkOrderHeader INNER JOIN WorkOrderDetail ON WorkOrderHeader.wono = WorkOrderDetail.wono
GROUP BY WorkOrderDetail.partno
WHERE WorkOrderHeader.status < 0;
Query2
SELECT InvItem.item, InvLoc.lonhand, Query1.MatAllocated, Query1.MinReqDate
FROM InvItem INNER JOIN InvLoc ON InvItem.item = InvLoc.item INNER JOIN Query1 ON InvItem.item = Query1.partno
WHERE [InvItem.ionhand]-[Query1.MatAllocated]-[InvLoc.orderpt]+[InvLoc.lonordr]) <= 0;
Thanks!
Adrian