S
Simon Harris
Hi All,
I am trying to build a query which gives me the sum of labour costs for a
specific job.
Stored in TBL_Labour_Log is number of hours, staff_id, job_id
Stored in TBL_Staff is name, rate_of_pay
I have tried the following:
SELECT TBL_order_time_log.order_id, TBL_order_time_log.Idate,
TBL_employees.first_name, TBL_employees.surname,
TBL_order_time_log.hours_spent, TBL_employees.Rate_of_Pay,
Sum([hours_spent]*[Rate_Of_Pay]) AS LabourSubTotal
FROM TBL_employees INNER JOIN TBL_order_time_log ON TBL_employees.ID =
TBL_order_time_log.staff_id
GROUP BY TBL_order_time_log.order_id, TBL_order_time_log.Idate,
TBL_employees.first_name, TBL_employees.surname,
TBL_order_time_log.hours_spent, TBL_employees.Rate_of_Pay
HAVING
(((TBL_order_time_log.order_id)=[forms]![frm_switchboard]![SUBFRM_view_order
s]));
Which works, and gives me a row for each log of hours recorded, along with
the total amount in money (e.g: 2hrs @ £15 p/hr correctly gives me £30)
What I really need is the total amount in money, so I tried amending the
query as follows:
Sum(Sum([hours_spent]*[Rate_Of_Pay]))
When I run the query, Access errors:
'Cannot have aggregate function in expression
(sum(sum([hours_spent]*[rate_of_pay]))).'
Hopefully someone will understand what I'm trying to achieve (Sorry, cant
really explain better than I have!)
Kind regards,
Simon.
PS: Just had an Idea....could I have a query based on the above query, which
will then give me the sum of the column showing total in money???? Any
problems with basing a query on a query??
--
-
* Please reply to group for the benefit of all
* Found the answer to your own question? Post it!
* Get a useful reply to one of your posts?...post an answer to another one
* Search first, post later : http://www.google.co.uk/groups
* Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!
I am trying to build a query which gives me the sum of labour costs for a
specific job.
Stored in TBL_Labour_Log is number of hours, staff_id, job_id
Stored in TBL_Staff is name, rate_of_pay
I have tried the following:
SELECT TBL_order_time_log.order_id, TBL_order_time_log.Idate,
TBL_employees.first_name, TBL_employees.surname,
TBL_order_time_log.hours_spent, TBL_employees.Rate_of_Pay,
Sum([hours_spent]*[Rate_Of_Pay]) AS LabourSubTotal
FROM TBL_employees INNER JOIN TBL_order_time_log ON TBL_employees.ID =
TBL_order_time_log.staff_id
GROUP BY TBL_order_time_log.order_id, TBL_order_time_log.Idate,
TBL_employees.first_name, TBL_employees.surname,
TBL_order_time_log.hours_spent, TBL_employees.Rate_of_Pay
HAVING
(((TBL_order_time_log.order_id)=[forms]![frm_switchboard]![SUBFRM_view_order
s]));
Which works, and gives me a row for each log of hours recorded, along with
the total amount in money (e.g: 2hrs @ £15 p/hr correctly gives me £30)
What I really need is the total amount in money, so I tried amending the
query as follows:
Sum(Sum([hours_spent]*[Rate_Of_Pay]))
When I run the query, Access errors:
'Cannot have aggregate function in expression
(sum(sum([hours_spent]*[rate_of_pay]))).'
Hopefully someone will understand what I'm trying to achieve (Sorry, cant
really explain better than I have!)
Kind regards,
Simon.
PS: Just had an Idea....could I have a query based on the above query, which
will then give me the sum of the column showing total in money???? Any
problems with basing a query on a query??
--
-
* Please reply to group for the benefit of all
* Found the answer to your own question? Post it!
* Get a useful reply to one of your posts?...post an answer to another one
* Search first, post later : http://www.google.co.uk/groups
* Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!