Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. nth highest salary

nth highest salary

Scheduled Pinned Locked Moved Database
helptutorialcareer
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sudharsong
    wrote on last edited by
    #1

    hi all, i just want to know how to get the nth highest salary from employee table.any help appreciated.

    with regards, susa

    A A P 3 Replies Last reply
    0
    • S sudharsong

      hi all, i just want to know how to get the nth highest salary from employee table.any help appreciated.

      with regards, susa

      A Offline
      A Offline
      Arvind Srivastava
      wrote on last edited by
      #2

      select top 1 sal from (select top 6 from emp order by sal asc) order by sal desc

      1 Reply Last reply
      0
      • S sudharsong

        hi all, i just want to know how to get the nth highest salary from employee table.any help appreciated.

        with regards, susa

        A Offline
        A Offline
        Ainapuram
        wrote on last edited by
        #3

        Try this SELECT empid,MAX(Salary) FROM Employees WHERE EmpID IN (SELECT TOP 2 EmpID FROM Employees ORDER BY Salary Desc) Muralidhar

        S 1 Reply Last reply
        0
        • A Ainapuram

          Try this SELECT empid,MAX(Salary) FROM Employees WHERE EmpID IN (SELECT TOP 2 EmpID FROM Employees ORDER BY Salary Desc) Muralidhar

          S Offline
          S Offline
          sudharsong
          wrote on last edited by
          #4

          hi, when im executed this query i got only the first two higher values even if i speciofied top 5 values thanks

          with regards, susa

          S 1 Reply Last reply
          0
          • S sudharsong

            hi, when im executed this query i got only the first two higher values even if i speciofied top 5 values thanks

            with regards, susa

            S Offline
            S Offline
            sudharsong
            wrote on last edited by
            #5

            hi boss , At last i got a solution for that problem. i used this one select min(sal) from(SELECT distinct TOP n sal FROM account ORDER BY Sal desc) as newsalary here instead of n we can give what ever the highest number we need.

            with regards, susa

            1 Reply Last reply
            0
            • S sudharsong

              hi all, i just want to know how to get the nth highest salary from employee table.any help appreciated.

              with regards, susa

              P Offline
              P Offline
              Paul Conrad
              wrote on last edited by
              #6

              Look at this thread a while back[^], I tested EricDV's suggestion and it works. Paul


              That's no moon, it's a space station. - Obi-wan Kenobi

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups