Subject | JOIN NOT WORKING CORRECTLY |
---|---|
Author | Dixon Epperson |
Post date | 2003-09-23T18:58:50Z |
I have the following query:
SELECT WH_STCK, WH_BC, SUM(WH_QTY), PR_NAME ||' '||PR_DESC,
PR_PARLVL, PD_QTY, PO_ETA
FROM WAREHOUSE JOIN PRODUCT ON (WH_STCK=PR_STOCKNO)
LEFT JOIN PODETAIL ON (PD_STCK LIKE WH_STCK ||'%')
LEFT JOIN POTABLE ON (PD_NUM=PO_NUM)
WHERE WH_LOCID='000011' AND WH_LOCSEQ=100 AND PO_LOCID=WH_LOCID AND
PO_LOCSEQ=WH_LOCSEQ AND PO_INV=''
GROUP BY WH_STCK, WH_BC, PR_NAME, PR_DESC, PR_PARLVL, PD_QTY, PO_ETA
HAVING SUM(WH_QTY) < PR_PARLVL *1.10
what it is supposed to do is get the product and sum of product in
warehouse that is less than 110% of the par-level plus return
quantities on a purchase order and the ETA of PO.
The query only works on the products that have a PO on them. Any
product in the warehouse which is less than parlevel, but doesn't
have a PO issued on it fails to show in this query.
I thought left join on this would take what is in the warehouse and
optionally add the PO data to it if it was there. What am I doing
wrong?
Dixon Epperson
SELECT WH_STCK, WH_BC, SUM(WH_QTY), PR_NAME ||' '||PR_DESC,
PR_PARLVL, PD_QTY, PO_ETA
FROM WAREHOUSE JOIN PRODUCT ON (WH_STCK=PR_STOCKNO)
LEFT JOIN PODETAIL ON (PD_STCK LIKE WH_STCK ||'%')
LEFT JOIN POTABLE ON (PD_NUM=PO_NUM)
WHERE WH_LOCID='000011' AND WH_LOCSEQ=100 AND PO_LOCID=WH_LOCID AND
PO_LOCSEQ=WH_LOCSEQ AND PO_INV=''
GROUP BY WH_STCK, WH_BC, PR_NAME, PR_DESC, PR_PARLVL, PD_QTY, PO_ETA
HAVING SUM(WH_QTY) < PR_PARLVL *1.10
what it is supposed to do is get the product and sum of product in
warehouse that is less than 110% of the par-level plus return
quantities on a purchase order and the ETA of PO.
The query only works on the products that have a PO on them. Any
product in the warehouse which is less than parlevel, but doesn't
have a PO issued on it fails to show in this query.
I thought left join on this would take what is in the warehouse and
optionally add the PO data to it if it was there. What am I doing
wrong?
Dixon Epperson