0

Can someone please look at my code and tell me where I am going wrong. I need to compare 2 tables and need to sum up to columns (temp.quantity) and cart1 (quantityout). Both tables have a common column called barcode. The code works when the temp table does not have duplicate rows of a particular barcode. I thought Sum() and group by barcode would add all the duplicates by barcode. But, it's not working. I also have negative and postive numbers, so I am only trying to add the positive numbers in that column.

<!--- UPDATE POSITIVE QUANTITY OUT INTO CART 1 --->
<cfquery name="SumQuantityOutTempAndCart1" datasource="inventory">
select Temp.Barcode,sum(cart1.QuantityOut+Temp.Quantity) AS SumQuantityOut
from Cart1,Temp
where Cart1.Barcode=Temp.Barcode and Temp.Quantity > -1
group by Temp.Barcode
</cfquery>

<cfoutput query="SumQuantityOutTempAndCart1">
<cfquery name="UpdateQuantityOutCart1" datasource="inventory">
UPDATE Cart1
SET QuantityOut = '#SumQuantityOut#'
WHERE Barcode = '#barcode#'
</cfquery>
</cfoutput>

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by arrgh
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.