-1

I always get an error message"You tried to execute a query that does not include the specified expression as part of an aggregate function."

Expr1:

IIf([Expiry Date]=Date(),"Due today","Not Yet Due")

also I want to count all the Due Date. What is the correct expression for this.

Hope someone can help. Thank you

HansUp
  • 95,961
  • 11
  • 77
  • 135

1 Answers1

0

You are obviously trying to create an aggregate query. Each field or expression must be assigned an aggregate function. In this case it appears need to GROUP BY results of the calculated field which means including in SELECT and GROUP BY clauses of aggregate query. Then an aggregation can give a count by the two values "Due today" and "Not Yet Due".

SELECT IIf([Expiry Date]=Date(), "Due today", "Not Yet Due") AS Status, Count(*) AS CountStatus 
FROM tablename 
GROUP BY IIf([Expiry Date]=Date(), "Due today", "Not Yet Due");

Then I expect want to consider only records where [Expiry Date] is in future.
WHERE [Expiry Date] >= Date()

June7
  • 19,874
  • 8
  • 24
  • 34