shaikh akbar
shaikh akbar

Reputation: 11

query does not include the specified expression 'ColB' as part of an aggregate function

I am using this query and it is working perfect but in excel as a database, it is giving me an error of aggregate function - solution: once I add all column in the group by I don't get sum and Group by doesn't work.

select ColA,ColB,ColC,ColdD,SUM(ColE),ColF,ColG FROM automate GROUP BY ColA

One picture indicates table structure:

table

Another one is expected output:

table

Please help me if someone knows- MS-Access / excel as database

Upvotes: 0

Views: 35

Answers (1)

SunKnight0
SunKnight0

Reputation: 3351

Every field in your SELECT part must be either GROUPed BY or aggregated. If all values are guaranteed to be the same or if you don't care which value will be picked use FIRST(), otherwise use the appropriate aggregate function (MIN, MAX, FIRST, LAST, SUM, etc.)

Example:

SELECT ColA, FIRST(ColB), FIRST(ColC), FIRST(ColdD), SUM(ColE), FIRST(ColF), FIRST(ColG) FROM automate GROUP BY ColA

Upvotes: 0

Related Questions