
July 9th, 2012, 08:38 PM
|
|
Registered User
|
|
Join Date: Jul 2012
Posts: 2
Time spent in forums: 16 m 27 sec
Reputation Power: 0
|
|
|
Summing values in coumn 1 based on vals in another column
Hello all:
I have a table with the following data:
Code:
id name amount refid
1 John 100.00 1
2 John 50.00 1
3 James 100.00 3
4 James 25.00 3
5 James 75.00 3
6 George 25.00 6
7 Karl 25.00 7
8 Karl 100.00 7
What I am trying to do is sum amount based on the refid. Id is a unique value in the db (not the primary key), and refid is what ties all of the like records (based on name) together.
I would like my results to look like the following:
Code:
Name Sum
John 150.00
James 200.00
George 25.00
Karl 125.00
I'm pretty sure I have to do a subquery of some sort, but I can't get it down.
Any help is greatly appreciated
Juan
|