I need help with the SUM function. I am trying to calculate the invoice amount for the same account in one total amount, but the results I get show that my SUM column only multiplies my first column by 3.
Here is what I want as the results for my layout data:
AccountNumber Bill BillDate 1 100.00 1/1/2013 1 150.00 2/1/2013 1 200.00 3/1/2013 2 75.00 1/1/2013 2 100.00 2/1/2013
Query:
SELECT AccountNumber, Bill, BillDate, SUM(Bill) FROM Table1 GROUP BY AccountNumber, Bill, BillDate AccountNumber Bill BillDate SUM(Bill) 1 100.00 1/1/2013 450.00 1 150.00 2/1/2013 450.00 1 200.00 3/1/2013 450.00 2 75.00 1/1/2013 175.00 2 100.00 2/1/2013 175.00
OR
AccountNumber Bill SUM(Bill) 1 100.00 450.00 2 75.00 175.00
I would prefer, if possible, both results.
Here is what I get:
My SUM column is simply multiplied by three, it does not actually summarize the data based on the account number.
AccountNumber Bill BillDate SUM(Bill) 1 100.00 1/1/2013 300.00 1 150.00 2/1/2013 450.00 1 200.00 3/1/2013 600.00 2 75.00 1/1/2013 225.00 2 100.00 2/1/2013 300.00
function sql group-by sum
Jason
source share