A
Aldred@office
Hi all,
I have 2 queries. I comebined them but some records are missing. The
situation is as follow:
Query 1:
SELECT Distinct PartNumID AS PID, Manu, POOutNum, PartNum, Quantity,
DueDate, tPOItems.DeliveryDate, SpecialInst
FROM tManu, tPOin, tPOItems, tPOOut, tDelivered
WHERE POinNum=Forms!fReport!POinNumDelivered
And tPOin.ID=tPOItems.POinID
And tPOOut.ID=tPOItems.POOutID
And tPOOut.ManuID=tManu.ID;
Result of Query 1:
PID Manu POOutNum PartNum Quantity DueDate DeliveryDate SpecialInst
95 HH 4729 108-X13 4730 23/9/2009 18/9/2009
33 HH 4729 108-R06 20000 23/9/2009 18/9/2009
38 HH 4729 108-F84 20000 23/9/2009 18/9/2009
Query 2:
SELECT Sum(tDelivered.DQuantity) AS Delivered
FROM tPOitems, tPOin, tDelivered
WHERE POinNum=Forms!fReport!POinNumDelivered
And tPOin.ID=tPOitems.POinID
And tPOitems.ID=tDelivered.POitemsID
And tDelivered.PartNumID=38;
Reult of Query 2:
Delivered
5000
Combined:
SELECT tPOItems.PartNumID AS PID, Manu, POOutNum, PartNum, Quantity,
Sum(DQuantity) As Delivered, DueDate, tPOItems.DeliveryDate, SpecialInst
FROM tManu, tPOin, tPOItems, tPOOut, tDelivered
WHERE POinNum=Forms!fReport!POinNumDelivered
And tPOin.ID=tPOItems.POinID
And tPOOut.ID=tPOItems.POOutID
And tPOOut.ManuID=tManu.ID
and tDelivered.PartNumID = tPOItems.PartNumID
and tPOitems.ID = tDelivered.POItemsID
Group by tPOItems.PartNumID, Manu, POOutNum, PartNum, Quantity, DueDate,
tPOItems.DeliveryDate, SpecialInst
Result of Combined Query:
PID Manu POOutNum PartNum Quantity Delivered DueDate DeliveryDate
SpecialInst
33 HH 4729 108-R06 20000 9000 23/9/2009 18/9/2009
38 HH 4729 108-F84 20000 5000 23/9/2009 18/9/2009
The problem is that in the Combined Query, the record with PID 95 is
missing. I know this makes sense because there is not delivered information
stored in the table "tDelivery". So how could I make my query shows all 3
records in the combined query just like the Query 1 does? In the Delivered
field, it will be best if it shows a zero but leaving it as blank is just
fine. Can some one please help me?
Thanks.
I have 2 queries. I comebined them but some records are missing. The
situation is as follow:
Query 1:
SELECT Distinct PartNumID AS PID, Manu, POOutNum, PartNum, Quantity,
DueDate, tPOItems.DeliveryDate, SpecialInst
FROM tManu, tPOin, tPOItems, tPOOut, tDelivered
WHERE POinNum=Forms!fReport!POinNumDelivered
And tPOin.ID=tPOItems.POinID
And tPOOut.ID=tPOItems.POOutID
And tPOOut.ManuID=tManu.ID;
Result of Query 1:
PID Manu POOutNum PartNum Quantity DueDate DeliveryDate SpecialInst
95 HH 4729 108-X13 4730 23/9/2009 18/9/2009
33 HH 4729 108-R06 20000 23/9/2009 18/9/2009
38 HH 4729 108-F84 20000 23/9/2009 18/9/2009
Query 2:
SELECT Sum(tDelivered.DQuantity) AS Delivered
FROM tPOitems, tPOin, tDelivered
WHERE POinNum=Forms!fReport!POinNumDelivered
And tPOin.ID=tPOitems.POinID
And tPOitems.ID=tDelivered.POitemsID
And tDelivered.PartNumID=38;
Reult of Query 2:
Delivered
5000
Combined:
SELECT tPOItems.PartNumID AS PID, Manu, POOutNum, PartNum, Quantity,
Sum(DQuantity) As Delivered, DueDate, tPOItems.DeliveryDate, SpecialInst
FROM tManu, tPOin, tPOItems, tPOOut, tDelivered
WHERE POinNum=Forms!fReport!POinNumDelivered
And tPOin.ID=tPOItems.POinID
And tPOOut.ID=tPOItems.POOutID
And tPOOut.ManuID=tManu.ID
and tDelivered.PartNumID = tPOItems.PartNumID
and tPOitems.ID = tDelivered.POItemsID
Group by tPOItems.PartNumID, Manu, POOutNum, PartNum, Quantity, DueDate,
tPOItems.DeliveryDate, SpecialInst
Result of Combined Query:
PID Manu POOutNum PartNum Quantity Delivered DueDate DeliveryDate
SpecialInst
33 HH 4729 108-R06 20000 9000 23/9/2009 18/9/2009
38 HH 4729 108-F84 20000 5000 23/9/2009 18/9/2009
The problem is that in the Combined Query, the record with PID 95 is
missing. I know this makes sense because there is not delivered information
stored in the table "tDelivery". So how could I make my query shows all 3
records in the combined query just like the Query 1 does? In the Delivered
field, it will be best if it shows a zero but leaving it as blank is just
fine. Can some one please help me?
Thanks.