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

  • Home
  • SEARCH
  • 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 8172767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:53:27+00:00 2026-06-06T21:53:27+00:00

I have a database in SQLServer in which there are multiple rows for a

  • 0

I have a database in SQLServer in which there are multiple rows for a database named emp_details. The table contains several fields, one of which is salary. The salary is not unique for the employees, and I need to fetch one complete row for each unique salary value.

Kindly let me know the query which may help.

A sample of the database:

a   b       c   d       e   f

17  IL11    53  IL11    48  58
26  IL10    53  IL10    48  58
31  IL15    53  IL15    48  58
32  IL16    53  IL16    24  58
33  IL17    53  IL17    36  58
34  IL18    53  IL18    36  58
37  IL21    53  IL21    36  58
40  IL24    53  IL24    48  58

I want to filter this on column e (assume it to be salary field)

  • 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-06T21:53:29+00:00Added an answer on June 6, 2026 at 9:53 pm

    Unsure if this is better performance wise as there is no schema. But this should work.

    WITH Emp_Salary
    AS
    (
        SELECT 
            Column1
            , Column2
            , Salary
            , ROW_NUMBER() OVER (PARTITION BY Salary ORDER BY Column1) r  --numbers each row uniquely per salary
            FROM emp_details
    )
    SELECT
        Column1
        , Column2
        , Salary
    FROM Emp_Salary
    WHERE r = 1 -- Filters all but the first row per salary.
    ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings, stack overflow In my database, I already have one table, 'contacts' that contains
I have a SQL Server database which I can read from, is there a
I have an Access application which use SQLServer 2008 R2 as database. When I
I have one SQL server database which was created using Import/Export Wizard from an
I have a SQL Server database which is shared between several ASP.NET (VB.NET) websites,
I have a WinForm application which uses SqlServer CE 3.5 as database. I use
I have a table with a few relational columns and one XML column which
I have a database table structured like this (irrelevant fields omitted for brevity): rankings
I have multiple apps running which access a sql server database. I had initially
I have VB Script which is connected with the my database (SQL Server 2008),

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.