Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 737747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:45:26+00:00 2026-05-14T07:45:26+00:00

I’m having trouble with Microsoft Access 2003, it’s complaining about this statement: select cardnr

  • 0

I’m having trouble with Microsoft Access 2003, it’s complaining about this statement:

select cardnr
from change
where  year(date)<2009
group by cardnr
having max(time+date) = (time+date) and cardto='VIP'

What I want to do is, for every distinct cardnr in the table change, to find the row with the latest (time+date) that is before year 2009, and then just select the rows with cardto=’VIP’.

This validator says it’s OK, Access says it’s not OK.

This is the message I get: “you tried to execute a query that does not include the specified expression ‘max(time+date)=time+date and cardto=’VIP’ and cardnr=’ as part of an aggregate function.”

Could someone please explain what I’m doing wrong and the right way to do it? Thanks

Note: The field and table names are translated and do not collide with any reserved words, I have no trouble with the names.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:45:26+00:00Added an answer on May 14, 2026 at 7:45 am

    Try to think of it like this – HAVING is applied after the aggregation is done.
    Therefore it can not compare to unaggregated expressions (neither for time+date, nor for cardto).

    However, to get the last (principle is the same for getting rows related to other aggregated functions as weel) time and date you can do something like:

    SELECT cardnr
    FROM change main
    WHERE time+date IN (SELECT MAX(time+date) 
                        FROM change sub
                        WHERE sub.cardnr = main.cardnr AND 
                              year(date)<2009 
                              AND cardto='VIP')
    

    (assuming that date part on your time field is the same for all the records; having two fields for date/time is not in your best interest and also using reserved words for field names can backfire in certain cases)

    It works because the subquery is filtered only on the records that you are interested in from the outer query.

    Applying the same year(date)<200 and cardto=’VIP’ to the outer query can improve performance further.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.