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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding record values

Status
Not open for further replies.

rincewind44

Programmer
May 21, 2003
33
0
0
IE
Hi,
I'm working off the following table
-------------------------------------------------
Key ID TeamName Points Rebounds
1 16 NCI 22 2
2 17 Knights 32 3
3 18 NCI 44 4
4 19 Knights 7 5
5 20 NCI 12 6
6 21 Knights 26 7
7 22 NCI 33 8
8 23 Knights 5 9
9 16 NCI 50 2
10 17 Knights 40 3
11 18 NCI 30 4
12 19 Knights 20 5
13 20 NCI 25 6
14 21 Knights 35 7
15 22 NCI 10 8
16 23 Knights 10 9
--------------------------------------------------------

I want to write an sql statement that will add up the total points and rebounds for each ID i.e. ID 16 would be 72 points and 4 rebounds.
I've tried using count and sum statements but they don't seem to work.
I'm fairly new to this so can any point me in the right direction?
Thanks
 
what about this:

[color]
select TeamName, sum(points), sum(rebounts)
From <TableName>
Group By TeamName
[/color]
 
Select ID, TeamName,
Sum(Points) As TotalPoints,
Sum(Rebounds) As TotalRebounds
From tbl
GROUP BY ID, TeamName
 
SELECT ID,
SUM(Points)as Total_Points,
SUM(Rebounds) as Total_Rebounds
FROM STATS_TABLE
GROUP BY ID

~Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top