want query

  • i want the query to find "second largest salary" from table.

  • select max(sal) from Emp_Salary

    where sal not in (select max(sal) from Emp_Salary)

  • select min(sal) from (select top 2 sal from Emp_Salary order by sal desc) a

  • to ignore rows of same sal

    select min(sal) from (select distinct top 2 sal from Emp_Salary order by sal desc) a

    or

    select min(sal) from (select top 2 sal from Emp_Salary group by sal order by sal desc) a

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply