Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to filter by the top 5? 1

Status
Not open for further replies.

Rmcta

Technical User
Nov 1, 2002
478
US
Not to play with real data, I have created a test table as follows:

Name Calls
Sabado 35
Daniel 41
Denise 42
Lisa 45
Ann 25
Bob 33
Susan 29
Jenn 39
Helen 37
Joe 36
Lori 38

How do I create a query that returns the people who made most calls? I must retrieve the TOP FIVE only.
This is just an example...my real table has hundreds of records and again I must only retrieve the top five.

Can that be done?

 
In the query grid sort the Calls field Descending and then in the toolbar there will be a Top Values option. It has a scroll arrow and is usually set to "ALL". Just click on the down arrow and select 5. That should do it.
 
Fantastic! Thank you very much :)
 
Now I have another problem..

Here is my sample data:

Calls date
45 1/1/2004
42 2/2/2004
41 1/1/2004
41 2/2/2004
39 1/1/2004
39 1/1/2004
38 2/2/2004
37 2/2/2004
36 1/1/2004
35 2/2/2004
35 1/1/2004
33 1/1/2004
29 2/2/2004
25 2/2/2004
21 2/2/2004

The following query:
SELECT TOP 5 tblCalls.Calls, tblCalls.date
FROM tblCalls
ORDER BY 1 DESC;

RETURNS:

Calls date
45 1/1/2004
42 2/2/2004
41 1/1/2004
41 2/2/2004
39 1/1/2004
39 1/1/2004

How do I obtain the top five for each day?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top