Use field for selection but NOT group by?

G

Guest

I have a data table. Right now there are four pertinent fields.

PPE Date
Function
Task
Total Hours

I would like to select records with date greater than 7/1/07. Then I'd like
to group by Function & Task and get the total hours for each pairing. In
other words, once the records are SELECTED, I'd like to ignore the PPE Date.
I get too many records to be useful if Access combines the date/function/task
fields for the grouping. I tried to use WHERE in the Total Row

My query is not allowing me to do this. I get an error:

You tried to execute a query that does not include the specified expression
'eBizHoursRecorded.PPEdate' as part of an aggregate function.

Is it possible to do this in a single query or do I have to use a subquery
to select the records and then do my total calculation?

Here's my SQL, just in case:

SELECT eBizHoursRecorded.Function, eBizHoursRecorded.Task,
eBizHoursRecorded.TotalHours
FROM eBizHoursRecorded
WHERE (((eBizHoursRecorded.PPEdate)>#7/1/2007#))
GROUP BY eBizHoursRecorded.Function, eBizHoursRecorded.Task,
eBizHoursRecorded.TotalHours
HAVING (((eBizHoursRecorded.Function) Not Like "gl*"))
ORDER BY eBizHoursRecorded.PPEdate, eBizHoursRecorded.Function,
eBizHoursRecorded.Task;

Thanks very much for your help.
 
G

Guest

Change your query to use a WHERE clause rather than HAVING, remove the
TotalHours from the GROUP BY, and sum the TotalHours.

SELECT Function, Task, Sum(TotalHours) as SumTotalHours
FROM eBizHoursRecorded
WHERE PPEdate>#7/1/2007# AND Function Not Like "gl*"
GROUP BY Function, Task
ORDER BY Function, Task;
 

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