I hope this doesn't violate any rules (i'm new, and yes i did check the FAQ).
But i have the following code
SELECT DISTINCT PO_NUMBER, PO_TRACKING_NO, SUPPLIER, MIN(PO_QUANTITY),
SUM(SHIPPED_WT), PO_SHIPMENT_TO
FROM VW_TRAFFIC_PO_SIDE
WHERE SYSDATE > PO_SHIPMENT_TO AND
(PO_QUANTITY > SHIPPED_WT OR PO_TRACKING_NO IS NULL)
GROUP BY PO_NUMBER, PO_TRACKING_NO, SUPPLIER, PO_SHIPMENT_TO
HAVING PO_QUANTITY > SUM(SHIPPED_WT)
It is suppose to do the following: Display 1 PO# per Tracking No, [this is the distinct, and it is correct, i was able to compiple the code successfully]...next, and this is the tricky part (this is the SUM, MIN, GROUP BY and HAVING parts): I needed to combine the SHIPPED_WT of any PO_NUMBER (that is displayed), and to show that combined number if it is less than the PO_Quantity
the where statement is also correct, as i compiled it successfully, it was only when i added the above part that i ran into trouble.
EDIT: the above code NOW compile (thanks to the answer below)
HOWEVER, my logic is wrong, and it does not do what i would want it to do..the one thing it does do correctly is grab 1 PO_NUMBER with 1 PO_TRACKING_NO (there can be duplicate po_numbers as long as the PO_tracking_no is different, and there can be duplicate tracking as long as the number is different)
EDIT: Below is what the relevant columns look like, and i will explain what is wrong with it (and what i tried to do with the code that was revised
PO_NUMBER PO_TRACKING_NO MIN(PO_QUANTITY) SUM(SHIPPED_WT)
123 C100 1000 750
123 C101 1000 250
the code was suppose to take records like this, and combine the SHIPPED_WT into one number (1000), and because that new number is = to the PO_QUANTITY, it should not appear in the query....in addition, the WHERE of PO_TRACKING_NO ISNULL is not working (all records with a null value in that field should be displayed, assuming it isn't a duplicate of a PO_NUMBER and PO_TRACKING_NO)