When I execute the following statement
SELECT DISTINCT OEL.item_no, OEL.qty_to_ship AS 'Total quantity Sold', OEL.sls_amt
FROM OEL
INNER JOIN OEH ON OEL.ord_no = OEH.ord_no
AND OEL.ord_type = OEH.ord_type
WHERE OEH.cus_no = '000000000027'
AND OEL.loc = 'SALES'
ORDER BY OEL.item_no
-----OUTPUT
07 .0000 .00
07 50.0000 69.38
07 50.0000 168.75
When I change the statement to sum the two field OEL.qty_to_ship and OEL.sls_amt.
SELECT DISTINCT OEL.item_no, SUM(OEL.qty_to_ship) AS 'Total quantity Sold', SUM(OEL.sls_amt)
FROM OEL
INNER JOIN OEH ON OEL.ord_no = OEH.ord_no
AND OEL.ord_type = OEH.ord_type
WHERE OEH.cus_no = '000000000027'
AND OEL.loc = 'SALES'
GROUP BY OEL.item_no
ORDER BY OEL.item_no
-----OUTPUT
07 200.0000 476.26
I believe that it should read
07 100.0000 238.13
The funny thing is that for some records it works just fine.
Thank you for your help
Mauro
SELECT DISTINCT OEL.item_no, OEL.qty_to_ship AS 'Total quantity Sold', OEL.sls_amt
FROM OEL
INNER JOIN OEH ON OEL.ord_no = OEH.ord_no
AND OEL.ord_type = OEH.ord_type
WHERE OEH.cus_no = '000000000027'
AND OEL.loc = 'SALES'
ORDER BY OEL.item_no
-----OUTPUT
07 .0000 .00
07 50.0000 69.38
07 50.0000 168.75
When I change the statement to sum the two field OEL.qty_to_ship and OEL.sls_amt.
SELECT DISTINCT OEL.item_no, SUM(OEL.qty_to_ship) AS 'Total quantity Sold', SUM(OEL.sls_amt)
FROM OEL
INNER JOIN OEH ON OEL.ord_no = OEH.ord_no
AND OEL.ord_type = OEH.ord_type
WHERE OEH.cus_no = '000000000027'
AND OEL.loc = 'SALES'
GROUP BY OEL.item_no
ORDER BY OEL.item_no
-----OUTPUT
07 200.0000 476.26
I believe that it should read
07 100.0000 238.13
The funny thing is that for some records it works just fine.
Thank you for your help
Mauro