Sum of ? Where ? = ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I am trying to create a query where it will add all the hours worked on a
specific job. My logsheets have entries where, for each logsheet, there will
be multiple entries with hours worked on each, with a 'duty' for each entry
such as ' In Port' or 'On Board' or 'Sailing'. I need to be able to run a
query where i can enter a parameter of eg, 'Sailing' and then it will show me
all the hours worked on that specific duty.
My query has a field with a calculation in it already which works out the
hours for that entry according to what was entered time-wise. this is it and
it works fine:

=Round(IIf((DateDiff("n",[Time on Duty],[Time off
Duty])/60)<0,(DateDiff("n",[Time on Duty],[Time off
Duty])/60)+24,(DateDiff("n",[Time on Duty],[Time off Duty])/60)),2)

I then need my calculation to be based on the answers in this column to be
added according to 'Sailing' or 'Launch', etc.

Please help. Thank you.
Rigby
 
Assuming this field is called Category, you could do something like the
following:

SELECT PersonID, Category, Sum(Hours) from tablename GROUP BY PersonID,
Category

This results in 3 columns, and 1 row per category for each emp.

1, Sailing, 25
1, On Dock, 15
1, Overboard, 10
etc.
 
Back
Top