Home > Ask the Oracle Experts > Questions & Answers > Top ten sales for each salesman
Ask The Oracle Expert: Questions & Answers
EMAIL THIS

Top ten sales for each salesman

Rudy Limeback EXPERT RESPONSE FROM: Rudy Limeback

Pose a Question
Other Oracle Categories
Meet all Oracle Experts
Become an Expert for this site
>
QUESTION POSED ON: 17 May 2004
I'll pose the question like this: I have an Access database, and a table with all the individual sales for five different salesmen. I want a query that will give me the top ten sales for each salesman.

>
EXPERT RESPONSE

This query, like so many other queries dealing with "top N" results, contains within it the thorny issue of what to do about ties. I'm not even going to mention the issue beyond saying that you should be prepared for the inevitable questions from your users.

In Access, you can use TOP syntax. This makes the necessary correlated subquery a lot easier to write.

select s.id
     , s.name
     , s.sales
  from salestable s
 where s.sales 
    in (
       select top 10
              sales
         from salestable
        where id = s.id 
       order
           by sales desc    
       ) 
order
    by s.id
     , s.sales desc

For More Information


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Oracle White Papers: Fusion Middleware
HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2003 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts