Re: Query expression Help
- From: "Ken Snell \(MVP\)" <kthsneisllis9@xxxxxxxxxxxxxxxxxx>
- Date: Thu, 24 May 2007 16:04:14 -0400
Sorry. ... my error. I neglected to note that you were putting a Criteria on
an aggregate function field.
However, before I try to provide a revised SQL statement for you, you need
to restate your logic. In the SQL statement that you posted, it appears that
you are wanting to sum the employee time for various employees, all in one
record. Don't you just want to show the sum of employee time for each
employee, in separate records? The WHERE clause syntax that you're showing
will always return zero records because it appears you want to select
records where the employee name field contains all three employee names,
which is not possible.
So, state in words what you want the query to do, and let's go from there.
--
Ken Snell
<MS ACCESS MVP>
"Chad" <Chad@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:69286534-CACC-4015-9CB4-D544E5C9A478@xxxxxxxxxxxxxxxx
Its giving me an error Cannot have aggreate function in Where
clause(tblMain.[DAYS DATE] Between [Enter Week Begining: (mm/dd/yy)] And
[Enter Week Ending: (mm/dd/yy)] And Sum([EMPLOYEE TIME])="Chad Zablackas"
And
Sum([EMPLOYEE TIME])="Lenny Lamatrice" And Sum([EMPLOYEE TIME])="Jim
Balvin"). Here is the SQL.
SELECT tblMain.FOOTAGE, tblMain.[Product Description], tblMain.Supervisor,
tblMain.Shift, tblMain.[EMPLOYEE NAME], tblMain.[DT REGULAR],
tblMain.[Machine Ran], tblMain.[Total Footage], tblMain.[DAYS DATE],
tblMain.[EMPLOYEE TIME], ([DT REGULAR])/([EMPLOYEE TIME]-[DT Reason 1]-[DT
MAINTENANCE]-[DT Reason 2]) AS [Delay Percent], tblMain.[DT Reason 1],
tblMain.[DT Reason 01], tblMain.[DT Reason 2], tblMain.[DT Reason 02],
tblMain.[DT MAINTENANCE], Sum([EMPLOYEE TIME]) AS [Chad Zablackas],
Sum([EMPLOYEE TIME]) AS [Lenny Lamatrice], Sum([EMPLOYEE TIME]) AS [Jim
Balvin]
FROM tblMain
WHERE (((tblMain.[DAYS DATE]) Between [Enter Week Beginning: (mm/dd/yy)]
And
[Enter Week Ending: (mm/dd/yy)]) AND ((Sum([EMPLOYEE TIME]))="Chad
Zablackas") AND ((Sum([EMPLOYEE TIME]))="Lenny Lamatrice") AND
((Sum([EMPLOYEE TIME]))="Jim Balvin"))
ORDER BY tblMain.Shift;
"Ken Snell (MVP)" wrote:
Field: Bill Black: Sum([EMPLOYEE TIME])
Criteria: "Bill Black"
--
Ken Snell
<MS ACCESS MVP>
"Chad" <Chad@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:F17EBDB0-B368-4F7E-BA2A-C73C23EE4318@xxxxxxxxxxxxxxxx
Not quite sure I understand what you mean. Can I do it this way? But it
asks
for the SumOfEMPLOYEE TIME when I run the query? I have to do this for
3
supervisors..Thanks!
Field: Bill Black: [SumOfEMPLOYEE TIME]
Criteria: "Bill Black"
"Ken Snell (MVP)" wrote:
SELECT EmployeeName, Sum([EMPLOYEE TIME]) AS TotalEmpTime
FROM TableName
WHERE EmployeeName = 'Bill Black'
GROUP BY EmployeeName;
--
Ken Snell
<MS ACCESS MVP>
"Chad" <Chad@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:6D4FF467-179C-4ACB-8997-46F1D2DD952B@xxxxxxxxxxxxxxxx
Hello, I have a query that I want to have an expression and I wnat
to
use
it
on a RPT but everytime I write it it asks the expression after it
asks
for
my
date range. I want to sum EMPLOYEE TIME for a perticular supervisor
say
Bill
Black. How would I write this in the query as an expression and the
criteria
being Bill Black?
Thanks!
.
- Follow-Ups:
- Re: Query expression Help
- From: Chad
- Re: Query expression Help
- References:
- Re: Query expression Help
- From: Ken Snell \(MVP\)
- Re: Query expression Help
- From: Ken Snell \(MVP\)
- Re: Query expression Help
- From: Chad
- Re: Query expression Help
- Prev by Date: Re: Invalid Syntax
- Next by Date: Re: Invalid Syntax
- Previous by thread: Re: Query expression Help
- Next by thread: Re: Query expression Help
- Index(es):
Relevant Pages
|