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

  • Home
  • SEARCH
  • 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 6073517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:16:46+00:00 2026-05-23T10:16:46+00:00

If the question doesn’t seem very clear, it should be after this explanation !

  • 0

If the question doesn’t seem very clear, it should be after this explanation !

Here is my table: Flights (AC, hours, cycles, flight_date)
ac = aicraft
hours = total aircraft hours
cycles = total aircraft cycles (cycle = flight)
flight_date = self explanatory 🙂

I’m trying to write a query that will give me the number of hours/cycles all AC have reached on a specific date.
(Keep in mind aircrafts can make a few flights a day, or no flight at all)

Here is what I wrote:

SELECT ac, hours, max(cycles)
FROM flights
WHERE flight_date <= cdate(asked_date)  //so access asks me for the date when I run the query
GROUP BY ac, hours

but for some reason, this doesn’t work:

It returns all the flights from all the aircraft where flight_date <= asked_date (looks like the MAX isn’t taken into account at all).

I considered using TOP 1 with a subquery but couldn’t find how to do it.
I’m using max(cycles) since if the cycle length is < 1h, we can get records with the same hours, but the cycles will still be different by definition.

What am I missing ?

  • 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-23T10:16:46+00:00Added an answer on May 23, 2026 at 10:16 am

    You need to put max also around the hours column and group only by ac:

    SELECT ac, max(hours), max(cycles)
    FROM flights
    WHERE flight_date <= cdate(asked_date)
    GROUP BY ac
    

    Reason:
    As the hours column contains the total hours of the aircraft, grouping by this value, will return you (nearly) all rows, because the value is different in each row. It will only group this rows that have the same value of total hours for a specific aircraft.

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

Sidebar

Related Questions

Yes, there is a similar question here . However, that question doesn't seem to
I know that question doesn't make much sense, but here goes: Times Table Authority
I am very sorry if my question doesn't make sense as this is my
This question doesn't relate only to MouseEvent.CLICK event type but to all event types
This post asks this question but doesn't really give an answer, so I thought
I have a question about locking. This doesn't have to be only about record
Just got a question about generics, why doesn't this compile when using a generic
(Hope this doesn't get duplicated; second attempt at submitting this question) I'm working on
I am sure the title of my question doesn't make much sense. But here
Sorry if this question doesn't make any sense. I'm currently in the midst of

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.