'FIELDNAME' not part of an aggregate function - Access SQL -


i trying select [operation]'s database , data each one. below sql code trying use.

the following error occurs:

you tried execute query not include specified expression 'op' part of aggregate function

my sql statement:

select [op] [operation], sum(count) [number of breakdowns], sum(td) [sum of time down] (   select [operation] op, count(*) count, sum([time down]) td   tbldailydowntimeassy   [type of maintenance] = 'breakdown' union   select [operation] op, count(*) count, sum([time down]) td   tbldailydowntimemach   [type of maintenance] = 'breakdown' ); 

note:

if try use [operation] field , don't rename op, error still occurs changes 'op' 'operation'

  select [operation], sum(count) [number of breakdowns], sum(td) [sum of time down] (   select [operation], count(*) count, sum([time down]) td   tbldailydowntimeassy   [type of maintenance] = 'breakdown'   group [operation] union   select [operation], count(*) count, sum([time down]) td   tbldailydowntimemach   [type of maintenance] = 'breakdown'   group [operation] ) group operation; 

you need add group clauses in queries using aggregate functions.


Comments