This Question is Answered 

    anon

    How Can I Get The Sixth Maximum Salary From The EMP Table? In SQL Server.

    asked 2 years ago

    Can't find what you're looking for?

    Ask a Question, Get an Answer ASAP


    Answers


    In the given examples suppose table name is emp.

    select max(sal) from emp e1 where (select count(sal) from emp e2 where e2.sal>=e1.sal)=6);


    Or you can use the following query.

    select distinct (a.sal) from emp A where &N=(select count(distinct b.sal)) from emp B where a.sal<=b.sal);

    After running this query it will ask value for N here you can give 6 as you want to get the sixth maximum salary.

    answered 2 years ago   

    New Comment

    1000 words left


      Categories

      What is Blurtit ?

      Ask questions on any topic, get great answers from real people for FREE. Blurtit has hundreds of thousand of members so your sure to get the answer your looking for.

      Ask a Question.