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

Sum for group of records

Status
Not open for further replies.

BrianLe

Programmer
Feb 19, 2002
229
US
For a material handling database, I have a table tblActivity with a field HandlingOptionID (1-10). Each record in the table has a StartDate, the HandlingOptionID and a weight (DBelt) specified.

For example

Handling
Date OptionID DBelt
2/2/08 1 30
2/4/08 1 50
2/4/08 2 60
2/5/02 3 20
2/6/02 3 50

I would like to create a report that will show for each HandlingOptionID the sum of DBelt for all the records with each particular HandlingOptionID.

I can get the sum of DBelt using DSum. However, I get one row for each record instead of a single row for each HandlingOptionID. I've also tried using a sub report.

How do I get a single row for each HandlingOptionID with the total DBelt value in the report?

Handling
OptionID DBelt (Sum)
1 80
2 60
3 50
etc.

Thanks,

Brian
 
Figured it out. Used the following query.

Code:
SELECT DISTINCTROW tblActivity.HandlingOptionID, Sum(tblActivity.DBelt) AS [Sum Of DBelt]
FROM tblActivity
GROUP BY tblActivity.HandlingOptionID;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top