+ Reply to Thread
Results 1 to 8 of 8

Top n results as a criterion

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Top n results as a criterion

    Years ago when I used Access I remember being able to limit the data downloaded from a database to the top 100 (or any other number) results of a chosen field.
    I have searched my available help sources in vain for a way to do this with Excel. Is it possible? If so how.
    John

  2. #2
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Top n results as a criterion

    you should have some sort LIMIT clause in your SELECT statment
    If you are pleased with a member's answer then use the Star icon to rate it.

  3. #3
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Top n results as a criterion

    What exactly are you doing in Excel? If you are using an Autofilter there is a Top 10 option that allows you to choose however many records you want remaining.
    Remember what the dormouse said
    Feed your head

  4. #4
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: Top n results as a criterion

    I have a very simple query selecting three fields from the database. I want to limit the download to those records that show the maximum 100 values from one of the (numerical) fields.
    I am looking for AutoFilter but can't as yet find it in Excel2007 .
    John

  5. #5
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Top n results as a criterion

    If you're using MSQuery have you tried simply altering the SQL to a SELECT TOP 100 query?

  6. #6
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: Top n results as a criterion

    romperstomper, Thanks for your interest. I have now found AutoFilter and the Top 10 option, and that will work, thank you.
    However what I was looking for was the SQL solution. In Access I think this must have been automated. I do not know the syntax. Is it just SELECT TOP n ?
    John

  7. #7
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Top n results as a criterion

    Yes - in conjunction with an ORDER BY clause so you get the right 'Top'.

  8. #8
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: Top n results as a criterion

    Please Login or Register  to view this content.
    If you want all columns,
    Please Login or Register  to view this content.
    There is an option in Microsoft SQL Management studio, you can right click on any table and one of the options is to select top 1000 rows

    st2k.PNG
    Last edited by Speshul; 08-22-2014 at 10:01 AM.
    You should hit F5, because chances are I've edited this post at least 5 times.
    Example of Array Formulas
    Quote Originally Posted by Jacc View Post
    Sorry, your description makes no sense. I just made some formula that looks interesting cause I had nothing else to do.
    Click the * below on any post that helped you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Find value based on item number (first criterion) and date (second criterion)
    By ivan.stajin in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-19-2014, 10:47 AM
  2. [SOLVED] Max If - Two Criterion
    By Ankedo in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-26-2014, 09:14 PM
  3. Add one more criterion in Combo box.
    By Pappachen in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-16-2013, 05:59 AM
  4. Replies: 3
    Last Post: 03-31-2010, 11:47 AM
  5. [SOLVED] How to Sum on Multiple Criterion
    By Don R in forum Excel General
    Replies: 5
    Last Post: 04-10-2005, 11:06 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1