Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Nov 2001
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SQL code for TOP 20 select query (Access '97)

    I have a table with 3 categories. I would like to select the top 20 records for each category (ie. total 60 records). Does anyone know if that can be done in a single select query and if so, what is the SQL code to do it?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: SQL code for TOP 20 select query (Access '97)

    You could try something like this, assuming your table is named Table1 and your category field is called Category and you only want to return a field called Customer for each unique category:

    SELECT TOP 60 Table1.Category, Table1.Customer
    FROM Table1
    GROUP BY Table1.Category, Table1.Customer;


    How you sequence the records to give you the "top" is a separate question.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •