-
Query top-three producers
I'm wondering if there is a way to do a "top three" sort of query. For instance, we have 83 facilities that we manage. Each facility has different departments. I want to be able to tell which three departments have the most number of records within each facility. Is there a way to craft a query that will give the results for the sub-groups with the most records? I would like the final report to look something like:
A. Facility A
i. Department with most records (count records within that department)
ii. Department with second most records
iii. Department with third most records
B. Facility B
i. and so on
-
-
Thank you, but the TOP n just displays the most recent entries for a query. I want it to count the number of records in a certain group and organize by how many records are in each, and then exclude from the results and records that are least represented by the data. i.e., one department has 50 complaints, another has 38, another has 21, and the others have less. I want only the ones with 50, 28, and 21 complaints to show up, because the other departments have less complaints than they do.
-
Well that reference gives you the general syntax, and explains the concept. I thought that was a good place to start.
What query have you tried? Can you show us the sql? What part exactly is the issue?
If you want someone to write the query for you, you're going to have to supply table structures, relationships and some sample data.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules