By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 1,998 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

Subquery help needed

P: n/a

tblDetails has the following fields:

AgencyCode, ProducerCode, AnnualPX

How can I create a query to show the Top 5 producers with the highest
PX per agency?

Can a subquery do it?

TIA

Oct 18 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
try something like this (air code)

Select top 5 PX, ProducerCode From
(select ProducerCode, Sum(AnnualPX) PX From tblDetails
Group By ProducerCode) t

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Oct 18 '06 #2

P: n/a
Thanks Rich.

However, I am trying to get the top 5 producers for each agency. - So,
I should get more than 5 records total.
Rich P wrote:
try something like this (air code)

Select top 5 PX, ProducerCode From
(select ProducerCode, Sum(AnnualPX) PX From tblDetails
Group By ProducerCode) t

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Oct 18 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.