954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

ColdFusion Sum() not adding up

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.



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

UPDATE Cart1
SET QuantityOut = '#SumQuantityOut#'
WHERE Barcode = '#barcode#'

geraldselectric
Newbie Poster
1 post since Jan 2012
Reputation Points: 10
Solved Threads: 0
 


Define "not working". What's it doing vs what you want it to do.

What db type?

arrgh
Posting Whiz
381 posts since Dec 2008
Reputation Points: 32
Solved Threads: 47
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You