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

Queries

Status
Not open for further replies.

nmapeso

Technical User
Aug 26, 2005
28
US
I have this table name Table 1 with the following data
ID Name Sin Interest
1 Noel 100 $23.00
2 Tim 101 $34.00
3 Jason 102 $34.00
4 Jason 102 $45.00
5 Andrea 103 $56.00
6 Andrew 104 $100.00
7 Rebecca 105 $34.00
8 Rebecca 105 $70.00
9 Angie 106 $57.00
10 Angie 106 $234.00
11 Andy 107 $23.00
12 Andy 107 $12.00
13 Noel 100 $12.45

Would like to create query if Sin are the same would add the Interest.
result would like this
ID Name Sin Interest
1 Noel 100 $35.45
2 Tim 101 $34.00
3 Jason 102 $79.00
4 Andrea 103 $56.00
5 Andrew 104 $100.00
6 Rebecca 105 $104.00
7 Angie 106 $291.00
8 Andy 107 $35.00
Thanks for any help
 
Hi!

Select Name, Sin, Sum(Interest) As [Total Interest] From YourTable Group By Name, Sin

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
Its fairly simple except for the ID column. Note that your input has (for example)

[tt]8 Rebecca 105 $70.00[/tt]

but your output has

[tt]8 Andy 107 $35.00[/tt]

If you can handle dropping the ID column then
Code:
Select [Name], Sin, SUM(Interest) As [Total Interest]

From myTable

Group By [Name], Sin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top