I've been visiting this site for a while now and many of the responses on here has been most helpful. However, I'm now stuck with an SQL that I can't seem to find just the right solution for.
(the $packplant and $ym is already defined earlier in the program)
SELECT 
    A.in_house_supplier_cd,
    B.maker_cd,
    A.packing_plant_cd,
    A.parts_no, 
    substr(A.actual_delivery_date,1,6), 
    A.actual_delivered_qty 
FROM 
    TRN_DELIVERY_NO A, 
    TRN_PARTS B 
WHERE 
    A.ISSUE_NO = B.ISSUE_NO 
    AND A.PACKING_PLANT_CD = '$packplant' 
    AND B.PACKING_PLANT_CD = '$packplant' 
    AND A.PARTS_NO = B.PARTS_NO 
    AND A.IN_HOUSE_SUPPLIER_CD = B.IN_HOUSE_SUPPLIER_CD 
    AND A.ACTUAL_DELIVERY_DATE LIKE '$ym%' 
ORDER BY 
    in_house_supplier_cd, maker_cd, parts_no;
This sql works fine. However, what I need is that the "A.actual_delivered_qt" to be sum(A.actual_delivered_qty)... in other words, I need the sum of that particular parts and not individual quantities that were received.
When I add the "sum.." part (or even with adding a GROUP BY parts_no), the sql gives a "column ambiguously defined" error.
I believe that I've already assigned the correct table to each column and therefore would really appreciate it if someone could point out the errors as I've been stuck with this for quite a while now. Cheers!
 
     
     
     
    