How can I get the second and third highest salary from the emp table

How can I get the second and third highest salary from the emp table in the ecah Department
SQL> ed
Wrote file afiedt.buf

  1  select empno, ename, sal, deptno
  2  from (
  3    select empno, ename, sal, deptno, dense_rank() over (partition by deptno order by sal desc) as rn
  4    from emp
  5    )
  6* where rn in (2,3)
SQL> /

     EMPNO ENAME             SAL     DEPTNO
---------- ---------- ---------- ----------
      7782 CLARK            2450         10
      7934 MILLER           1300         10
      7566 JONES            2975         20
      7876 ADAMS            1100         20
      7499 ALLEN            1600         30
      7844 TURNER           1500         30

6 rows selected.

SQL>

Tags: Database

Similar Questions

Maybe you are looking for

  • Cannot start normally my Qosmio

    All my programs crashed once and I had to click on the turn-off/on button and shut down the computer. I started the computer, but then she does not even recognize my code. I restarted again, and the computer started something repair. Then he asked ho

  • How can I enter my Office Mozilla with a password?

    I use Mozilla my access to the internet portal. Since I have some personal "bookmarks" can I use a password to enter Mozilla from my desktop, but I don't know how to do it. I use Google as my home page. Thank you.

  • HP LaserJet Pro M451nw

    Where can I find detailed instructions on how to set up printing wirelessly on HP 400 M451nw? Is it possible to have the two printing service via the USB port, as well as the wireless connection?

  • SmartDVD needs an update on Pavilion dv7 notebook

    I have a HP Pavilion dv7 with windows 7 and I just recently tried to play a new blu - ray disc in my drive and every time I do a window pops up asking me if I'd check updates "Yes or no", when I click Yes the window disappears and it seems as if the

  • Screen goes black when you use the computer - Vista

    Original title: SCREEN GOES BLACK, COMPUTER STILL WORKS. A MESSAGE CAME ON A MIRROR SCREEN, COMPUTER WORKS FINE IN SAFE MODECOMPUTER STARTS SOMETIMES, BUT SA SEEMS IF THE NETWORK IS ON THE DISPAY GOES OFF, A MESSAGE CAME ON SCREEN MIRROR, EVERYTHING