Top 10 within a few groups (1 Viewer)

Alc

Registered User.
Local time
Today, 09:59
Joined
Mar 23, 2007
Messages
2,407
I have a query that returns the following values:

Group_Name
Group_Priority
Person_Name
Amt_From
Amt_To
Branch
ID_Number

How can I select from this to get the top 10 'Amt_From' values within each Group_Name, in one query?

I can get the top 10 overall, and I can find the top 10 by specifiying a Group_Name value, but I'm hoping to find all in one query.

Any ideas gratefully received.
 

MStef

Registered User.
Local time
Today, 14:59
Joined
Oct 28, 2004
Messages
2,251
I'm afraid that you need 2 queryes.
 

Alc

Registered User.
Local time
Today, 09:59
Joined
Mar 23, 2007
Messages
2,407
Thanks for the response.

I can live with using two - could you point me in the right direction? I'm thinking a union of some sort, but not getting much further.
 

Alc

Registered User.
Local time
Today, 09:59
Joined
Mar 23, 2007
Messages
2,407
Got it!

I had to Union query the results of six separate queries, but it worked.

In case it's of any use to anyone else, the result looks like this:

Code:
(SELECT 
   Top 10 Amt_From,
   Amt_To,
   Group_Name, 
   Group_Priority, 
   Person_Name, 
   Branch, 
   ID_Number
FROM 
   [Qry_Conf_Lead_Board]
WHERE
   Group_Name = 'ATLANTIC')
UNION
(SELECT 
   Top 10 Amt_From,
   Amt_To,
   Group_Name, 
   Group_Priority, 
   Person_Name, 
   Branch, 
   ID_Number
FROM 
   [Qry_Conf_Lead_Board]
WHERE
   Group_Name = 'QUEBEC')
UNION
etc.
etc.

Thanks for the pointer, MStef. Made all the difference. :)
 

Users who are viewing this thread

Top Bottom