Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8634645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:46:30+00:00 2026-06-12T09:46:30+00:00

I am trying to find the n largest numbers in a particular column in

  • 0

I am trying to find the n largest numbers in a particular column in SQL Server.

We can find the largest value in a column and the 2nd largest value easily.

But how do I find say, 5 largest values in a column ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:46:31+00:00Added an answer on June 12, 2026 at 9:46 am

    In MySql you can use [LIMIT {[offset,] row_count }] to do this like so:

    ...
    ORDER BY SomeField DESC
    LIMIT @n; 
    

    For SQL Server you can use the TOP(n) to get the top n:

    SELECT TOP(@n) SomeFieldName
    FROM TABLE
    ORDER BY SomeField DESC
    

    For example:

    SELECT TOP 5 items_sold
    FROM tbl_PRODUCT 
    ORDER BY items_sold dESC
    

    Update: If you have another table families with a foreign key family_ID to products table, and you want to find all products with the top n family id’s. Then you can dot this:

       SELECT *
       FROM Products WHERE family_ID  IN
       (
           SELECT TOP 5 family_ID
           FROM families
           ORDER BY family_ID DESC
       )
    

    Update 2: The topmost product in each family:

    ;WITH cte
    AS
    (
        SELECT *, 
        ROW_NUMBER() OVER(PARTITION BY family_ID ORDER BY items_sold DESC) row_num
        FROM @Products
    )
    SELECT * FROM cte
    where row_num = 1
    Order by family_ID
    

    Here is alive demo

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to find the largest prime number contained within another large number.
I'm trying to find the largest prime factor of the number x, Python gives
I'm trying to find the largest prime factor of the number 600851475143. I dimmed
I am trying to write a program to find the largest prime factor of
I am trying to find the largest substrings which are in both strings (minimum
I am trying find out what is postgres can handle safely inside of transaction,
I am trying to solve the following problem: Find the largest palindrome made from
I'm trying to find the largest prime factor of the number 600851475143. My code
Trying to find: Show the top-20 PIs who have the largest total amount of
I want to find the largest palindrome that can be obtained through the multiplication

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.