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 6060969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:53:07+00:00 2026-05-23T08:53:07+00:00

I have an MS Access database that contains a table of dates, scores and

  • 0

I have an MS Access database that contains a table of dates, scores and the people to whom those scores relate, e.g.

Date   Score Name
1/6/11     5 Dave
1/6/11    10 Sarah
2/6/11     4 Dave
2/6/11     3 Graham
3/6/11     1 Dan
4/6/11    11 Dan
4/6/11     9 Graham

I would like to write a query to find who got the highest socre on each date, i.e. a result of:

Date   Score Name
1/6/11    10 Sarah
2/6/11     4 Dave
3/6/11     1 Dan
4/6/11    11 Dan

I can think of two solutions to this problem (I am open to alternative suggestions), as follows:

1) Write a query to find the minimum score for each date then a second query joining the first query to the original table. i.e.:

Query1:

SELECT Date, MAX(Score) AS MaxScore FROM ScoresTable GROUP BY Date

Query2:

SELECT ScoresTable.* 
FROM ScoresTable INNER JOIN Query1 
  ON ScoresTable.Date = Query1.Date 
  AND ScoresTable.Score = Query1.MaxScore

[These could be combined as a single query:

SELECT ScoresTable.* 
FROM ScoresTable INNER JOIN 
  (SELECT Date, MAX(Score) AS MaxScore 
  FROM ScoresTable GROUP BY Date) Query1 
  ON ScoresTable.Date = Query1.Date 
  AND ScoresTable.Score = Query1.MaxScore

but I prefer to keep them separate to make it easier for others to follow, i.e. they can use the Access interface without knowing SQL]

2) Write a single query with another simple query within the WHERE clause (this is a new method I have only just read about, does it have a name?), i.e.:

SELECT * FROM ScoresTable WHERE Score = 
  (SELECT MAX(Score) FROM ScoresTable AS st WHERE st.Date = ScoresTable.Date)

The latter is clearly more elegant, but appears to run more slowly. Which is the better option? The datasets can get quite large.

  • 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-23T08:53:08+00:00Added an answer on May 23, 2026 at 8:53 am

    Your single composite query already looks optimal to me, I doubt that you can do simpler or more efficient.
    Judicious use of indexes in your table should ensure that the query runs pretty fast.

    Your last query is called a Correlated subquery.
    It is sometimes useful, but can be very slow: the subquery will need to be executed for each record in the ScoresTable because the result of the subquery depends on the value of each individual record in ScoresTable.
    This is rather difficult for the database engine to optimise.

    If you are interested in finding out details about how the query planner optimises your queries, have a look at these articles, they’ll show you what’s under the hood:

    • Use Microsoft Jet’s ShowPlan to write more efficient queries
    • Access 2002 Desktop Developer’s Handbook, Chapter 15: Application Optimization
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a VB.net application with an Access Database with one table that contains
I have a ms access database that has one table for each photo album
I have a MS access database. In that, one table consists of questions and
I have an (access) database table which contains data I would like to populate
In my database I have a simple table that contains values showing the basic
I have an MS Access database that contains translated sentences in source-target pairs (a
I have an MEMORY MYSQL database that contains a table with 200k+ rows. I
I have an Access 2003 database that makes use of a combobox that contains
I have a database in Access 2003 that I only want certain people to
I have a legacy MS Access 2007 table that contains 52 fields (1 field

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.