Top values - Not working how I thought it would (1 Viewer)

Crackers

Registered User.
Local time
Tomorrow, 01:00
Joined
May 31, 2002
Messages
36
I have a Query that selects the total number of goals kicked by individual players for a season. [Aussie Rules Football].
The first field is the Total Goals which is sorted in descending order.
The Top Values field is put at 3.
I have 5 players who have kicked 18, 16, 17, 18 and 15 respectively. When I run the query, I am returned with just 18, 18 and 17. I need the query to show me 18, 17 and 16 (the top 3 goalkickers) which will include duplicates (ie: 18). What am I missing? Grateful for anyone's help!
 

David R

I know a few things...
Local time
Today, 10:00
Joined
Oct 23, 2001
Messages
2,633
If you right-click on the query grid in design view, you can get to the Properties list. One of them is for "Unique Values".
 

Crackers

Registered User.
Local time
Tomorrow, 01:00
Joined
May 31, 2002
Messages
36
I tried as you said, but I still only get 18, 18 and 17.
I put '3' as the Top Values and then clicked 'Yes' for Unique values.
What am I missing?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 10:00
Joined
Feb 28, 2001
Messages
27,195
You are getting exactly what you asked for. The top three entries are, indeed, <18,18,17> based on your example.

Your problem is, I think, that you are asking the wrong question.

If you want to see the top three kick numbers independent of kickers, you need to do something a bit more elaborate...

Make a query that does a group-by on goals in your stats table (and nothing else is in the query!) That becomes query #1.

Now make query #2 that takes the top 3 entries from query #1. Since there was nothing else in query #1 there will be nothing else in query #2, either. This query should return 18, 17, 16 as you said you wanted. At least I think it will.

Now, if you want to know EVERYONE who has kicked one of these top three numbers (in other words, allow duplicates at this stage), make query #3 that joins to your raw table where the goals field in both the table and query are equal and you keep all records from query #2.

HINT: In the query design grid, table-select section, you can define a relationship that isn't really defined in the master database relationship diagram. Just add your raw table and query #2 as the two contributors to this query. Then do a drag-and-drop of the goals from your query #2 to the goals field in the table. Make it so that you have all records from query #2 and all matching records from the table. This should do the trick.

I think your original problem is that in English your question isn't about the top three scorers, it is about the top three distinct score numbers. But when you add a person to the record and do the top three, even asking Access to make them unique.... they ARE! Because the combo of player and goals is unique no matter what.

My suggestion isolates the goal counts first, then goes back to pick up the matching players later. Given what you said you wanted to see, I think my solution will come close.
 

Crackers

Registered User.
Local time
Tomorrow, 01:00
Joined
May 31, 2002
Messages
36
Your suggestion was not just close, it was spot on. Thank-you very much for that.
 

Users who are viewing this thread

Top Bottom