user1342164
user1342164

Reputation: 1454

Is it possible to sum a expression column in access?

I have a column in access I need to get the total of. When I try the below method in my query I get the error "You tried to execute a query that does not include the specified expression 'ID' as part of an aggregate function."

Expr1: Sum([Column1])

Edit my query:

SELECT tblTest.ID,Field1,Sum([Field1]) AS Expr1 From tblTest;

Upvotes: 1

Views: 9755

Answers (1)

Taryn
Taryn

Reputation: 247880

Your question needs more details but I think you want this:

SELECT Sum(yourColumn)
FROM yourTable

Then if you need to you will have to add a GROUP BY

SELECT Sum(yourColumn)
FROM yourTable
GROUP BY yourTable.Id

Based on your comment your query would be:

SELECT ID
    ,Field1
    ,Sum([Field1]) AS Expr1 
From tblTest
GROUP BY ID, Field1;

Upvotes: 3

Related Questions