Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grouping fields and calculating total cost!!

Status
Not open for further replies.

eXtacy

Programmer
Dec 1, 2003
21
GB
Hi

I have created a query which gives an output of something like this:

IDNO NAME COST
34 Twigg £500
110 Rich £200
120 Gray £150
34 Twigg £2000
86 Kemp £100
86 Kemp £100
12 James £200

what i am trying to do is to group the ID numbers together and add the costs so that
i would get the total cost for each person.

This is what i am looking for:

IDNO NAME COST
34 Twigg £2500
110 Rich £200
120 Gray £150
86 Kemp £200
12 James £200

could someone please help me out here.....i am having real trouble to get it right.

Thanks a lot
regards.
 
Select IDNO, [NAME], SUM(Cost) As [TotalCost]
From tbl
Group By IDNO, [NAME]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top