Combining Fields that are Alike to get a Total Result

G

Guest

I want to combine the following so that I have one total for hours worked
under each cost code. Example; date-4/17/07, cost code 003 311301, 16 hours
and on 4/19, 003 311301, 7 hours, how do I combine each repeated cost code
for a grand total of hours. I am using Access 2003.

This is my Query: Table; Time Card Hours: Fields are DateWorked, JobNo,
CostCodes and my Expression field –MNhrs:
Sum([BillableHours]+[BillableOT]+[BillableDT])

Right now my data is like this:
Cost Codes MNhrs Cost Codes MNhrs
001 130006 1 001 130006 1
003 311301 3 003 311301 23
003 311301 10 003 311320 7
003 311301 2 003 311340 5.5
003 311301 2 003 312121 10
003 311301 6 004 331300 40.5
003 311320 7 004 331349 5
003 311340 5.5 005 311360 27
003 312121 10 005 333903 14
004 331300 11 999 205003 11
004 331300 29.5 999 205006 5
004 331349 3
004 331349 2
005 311360 12
005 311360 7
005 311360 2
005 311360 6
005 333903 8
005 333903 6
999 205003 11
999 205006 2
999 205006 1
999 205006 2

Thanx! All help will be fantastic!
Access Gal
 
C

Carl Rapson

AccessGal said:
I want to combine the following so that I have one total for hours worked
under each cost code. Example; date-4/17/07, cost code 003 311301, 16
hours
and on 4/19, 003 311301, 7 hours, how do I combine each repeated cost code
for a grand total of hours. I am using Access 2003.

This is my Query: Table; Time Card Hours: Fields are DateWorked, JobNo,
CostCodes and my Expression field -MNhrs:
Sum([BillableHours]+[BillableOT]+[BillableDT])

Right now my data is like this:
Cost Codes MNhrs Cost Codes MNhrs
001 130006 1 001 130006 1
003 311301 3 003 311301 23
003 311301 10 003 311320 7
003 311301 2 003 311340 5.5
003 311301 2 003 312121 10
003 311301 6 004 331300 40.5
003 311320 7 004 331349 5
003 311340 5.5 005 311360 27
003 312121 10 005 333903 14
004 331300 11 999 205003 11
004 331300 29.5 999 205006 5
004 331349 3
004 331349 2
005 311360 12
005 311360 7
005 311360 2
005 311360 6
005 333903 8
005 333903 6
999 205003 11
999 205006 2
999 205006 1
999 205006 2

Thanx! All help will be fantastic!
Access Gal

Look into the GROUP BY clause:

SELECT CostCode, SUM(MNhrs) FROM [Query] GROUP BY CostCode;

Carl Rapson
 
J

John W. Vinson

I want to combine the following so that I have one total for hours worked
under each cost code. Example; date-4/17/07, cost code 003 311301, 16 hours
and on 4/19, 003 311301, 7 hours, how do I combine each repeated cost code
for a grand total of hours. I am using Access 2003.

This is my Query: Table; Time Card Hours: Fields are DateWorked, JobNo,
CostCodes and my Expression field –MNhrs:
Sum([BillableHours]+[BillableOT]+[BillableDT])

Right now my data is like this:
Cost Codes MNhrs Cost Codes MNhrs
001 130006 1 001 130006 1
003 311301 3 003 311301 23
003 311301 10 003 311320 7
003 311301 2 003 311340 5.5
003 311301 2 003 312121 10
003 311301 6 004 331300 40.5
003 311320 7 004 331349 5
003 311340 5.5 005 311360 27
003 312121 10 005 333903 14
004 331300 11 999 205003 11
004 331300 29.5 999 205006 5
004 331349 3
004 331349 2
005 311360 12
005 311360 7
005 311360 2
005 311360 6
005 333903 8
005 333903 6
999 205003 11
999 205006 2
999 205006 1
999 205006 2

Thanx! All help will be fantastic!
Access Gal

Create a Totals query using the Greek Sigma icon (looks like a sideways M).
Group By [Cost Codes] and put your expression for MNHrs into a vacant Field
cell, and change the Totals row for that field to Sum.

John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top