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 7839605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:29:23+00:00 2026-06-02T15:29:23+00:00

I am really confused how to write query for the following statement. How to

  • 0

I am really confused how to write query for the following statement.

How to display top 5 employees with the highest number of sales (total) and display position as a field. Note that if both of employees have the same total sales values they should receive the same position, in other words Top 5 employees might return more than 5 employees?

Anyone can suggest an answer for this?

  • 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-02T15:29:28+00:00Added an answer on June 2, 2026 at 3:29 pm

    Something like:

    WITH cte AS (
        SELECT
            Rank() OVER (ORDER BY SUM(salary) DESC ) AS [Rank]
            , SUM(salary) as sum
            , Employee
        FROM 
            [table]
        GROUP BY
            Employee
    )
    SELECT  * 
    FROM cte 
    WHERE [RANK] < 5
    ORDER BY sum DESC    
    

    I re-read your question and it seems that you’re looking for the top count of sales rather than sum of salary, but of course, in that case you can just use COUNT(sales) in the OVER statement.

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

Sidebar

Related Questions

I'm really getting confused by how many different ways there is to write data
So I am really confused on how to write this proc. Here is what
I am really confused about object relationships! I have two classes Person and Address.
I'm really confused by a behaviour of LINQ I'm seeing and it's causing me
I am really confused now on how and which method to use to return
I'm really confused about the visitor pattern and its uses. I can't really seem
I'm really confused with an array im making, its gotten a bit confusing to
i'm really confused how to name method names in Ruby classes. if i create
I'm really confused. I want to make a Chrome Extension that can update a
I am getting really confused with this concept: If I want to implement a

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.