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

Group Different Records in Access 1

Status
Not open for further replies.

gall3on

Technical User
Mar 15, 2007
35
US
I need help in generating the SQL query for grouping distinct records into one record and summing up values. The query needs to go through a table and group several records together. The results need to show the grouped records plus distinct records.

sample table:

Name Total TotalX TotalY
A1 6 7 8
A2 1 2 3
A3 2 4 5
B1 1 2 3
B2 1 3 5

result needed:
Name Total TotalX TotalY
Combined A 9 13 16
Combined B 2 5 8

Thanks!

 
Code:
SELECT Left(tblData.Name,1) AS [Name], 

Sum(tblData.Total) AS Total, 
Sum(tblData.TotalX) AS TotalX, 
Sum(tblData.TotalY) AS TotalY

FROM tblData

GROUP BY Left(tblData.Name,1);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top