How to find the third highest salary from deptno20,from employee table

how to find the third highest salary from deptno20,from employee table

SELECT *
  FROM emp;
EMPNO
ENAME
JOB
MGR
HIREDATE
SAL
COMM
DEPTNO
7369
SMITH
CLERK
7902
12/17/1980
1000
3
20
7499
FEDERAL
SALESMAN
7654
2/20/1981
2000
4
30
7521
WARD
SALESMAN
7698
2/22/1981
3000
4
30
7566
JONES
MANAGER
7839
4/2/1981
4000
3
20
7839
MARTIN
SALESMAN
7698
9/28/1981
5421
4
30
7698
BLAKE
MANAGER
7698
5/1/1981
6222
4
30
7782
CLARK
MANAGER
7839
6/9/1981
5222
2
10
7788
SCOTT
ANALYST
7566
12/9/1982
5463
3
20
7839
KING
PRESIDENT
7902
11/17/1981
8543
2
10
7844
TURNER
SALESMAN
7698
9/8/1981
2124
4
30
7876
ADAMS
CLERK
7788
1/12/1983
2125
3
20
7900
JAMES
CLERK
7698
12/3/1981
5462
4
30
7902
FORD
ANALYST
7566
12/3/1981
2132
3
20
7934
MILLER
CLERK
7782
1/23/1982
5165
2
10
SELECT sal, deptno
  FROM (SELECT   a.*,
                 DENSE_RANK () OVER (PARTITION BY deptno ORDER BY sal DESC) r
            FROM emp a
      ----  ORDER BY sal DESC
WHERE r = 3;
SAL
DEPTNO
5421
30
5165
10
2132
20
Regards ,
Friend
Message was edited by: MostWanted!!!!

Similar Messages

  • How to find the third highest salary by distinct the salary from deptno20,from employee table

    how to find the third highest salary by distinct the salary from deptno20,by using employee table

    You already asked this question, a half hour earlier:
    https://forums.oracle.com/thread/2569985
    and received a reply.
    Do not multi-post to the forums.
    These are user-to-user forums and everyone is posting because they volunteer to post and not because they get paid to post.    Everyone else is paid exactly the same as you are paid to post here.   When you multi-post is makes you appear as impatient and expecting instantaneous answers.
    That is poor forum etiquette, approaching behavior similar to spamming the forums.
    This duplicate post is locked.

  • How to find the file that delete from time capsule?

    How to find the file that delete from time capsule?

    I mean I saved JPEG file in Time capsule and unfortunately delete the file. Can I get it back
    IF.... .no other backups have occured since you deleted the file, you might be able to retrieve it using an application like Disk Warrior. It's about $100 as I recall, and there are no guarantees that it will work.
    DiskWarrior 4 - The Disk Utility for Mac  Disk Repair, Mac Directory ...
    Any of the free or low priced utilities that you might see or try will not be able to retrieve a deleted file from a Time Capsule.
    If any backups have occured since you deleted the file, the deleted file has almost certainly been overwritten. No way to retrieve it in that case.

  • Nth Highest Salary from EMP table , need explaination

    I am new to the database world and hence learning queries at the initial stages. I want to retrieve the nth highest salary from the EMP table. I was not able to find out the answer by myself , so I searched on google. The following was the answer i got :
    SELECT DISTINCT (a.sal) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B WHERE a.sal<=b.sal);
    Enter value for n: 2
    SAL
    3700
    Suppose the table contains salary in the following order :
    SAL
    2000
    3000
    3700
    4000
    3700
    2000
    So how come I will get the correct answer with the abov query ? I am not able to understand the part --- WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B WHERE a.sal<=b.sal);
    Specially the condition WHERE a.sal<=b.sal is very confusing to me. Can anyone help me please to understand the same.

    user12328699 wrote:
    I am new to the database world and hence learning queries at the initial stages. I want to retrieve the nth highest salary from the EMP table. I was not able to find out the answer by myself , so I searched on google. The following was the answer i got :
    SELECT DISTINCT (a.sal) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B WHERE a.sal<=b.sal);
    Enter value for n: 2
    SAL
    3700
    Suppose the table contains salary in the following order :
    SAL
    2000
    3000
    3700
    4000
    3700
    2000
    So how come I will get the correct answer with the abov query ? I am not able to understand the part --- WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B WHERE a.sal<=b.sal);
    Specially the condition WHERE a.sal<=b.sal is very confusing to me. Can anyone help me please to understand the same.There is many better way to get the nth highest salary
    But still if you want to understand the same.
    Assuming the data is sorted in ascending order, then
    1) a.sal=2000, so a.sal<=b.sal results in count as 3 (not equal to user input)
    2) a.sal=3700, so a.sal<=b.sal results in count as 2 (equal to user input)
    3) a.sal = 4000 , so a.sal<=b.sal results in count as 1 (not equal to user input)
    Hence the answer is 3700
    Regards
    Anurag

  • How to get second maximum salary from employee table(sql query)

    how to get second maximum salary from employee table(sql query)

    dude there is no matter of structure .........that user already said its from employee table ...............its basic table in sql and there is no need to specify the table structure
    .........i think u got my point I think you are the one who didn't understand Sarma's point.
    Give a man a fish and you feed him once. Teach a man how to fish and you feed him a life long.
    >
    and the query is
    select max(sal) from emp where sal<(select max(sal)
    from emp);
    this will give the 2nd max salary from the emp tableBtw: You solution is bad, because it needs to scan and sort the table emp twice. And a better solution has been given already.
    Message was edited by:
    Sven W. - reordered statements

  • How to find the cost center group from cycle/ segment in CO module?

    Hi All,
    I need to fetch the list of cost centers in the cost center group against the cycle.
    Is there any table which will store the list of cost centers against the cycle?
    or else, what I was thinking is use of BAPI BAPI_COSTCENTERGROUP_GETDETAIL, which will give me the list of cost centers,
    but we need to pass the controlling area + cost center grp to fetch the cost centers from BAPI, I have controlling area with me but not the cost center grp name, only I have Cycle info lke cycle name, segment name, seq number. so how to find the cost center grp name from the cycle name?
    Regards,
    Mrunal

    FM: RK_AL_CYCLE_READ
    CHECK TABLE: T811K

  • How to find the contents of proc from top command

    I had a doubt related to how to find the contents of a procedure or the statements from the PID displayed in top command if it can be done from TOAD or
    sqlplus. If we can find out the details from top like:-
    21211 oracle 16 0 3228 1012 764 R 0 0.0 0:07.68 top
    1 root 16 0 1732 552 472 S 0 0.0 0:01.29 init
    say, what is the process with PID 21211 and 1 are doing?
    I hope, my question is clear.
    Please, help in solving the doubt.
    regards

    Join v$process, v$session, and v$sql
    SQL> ed
    Zapisano file afiedt.buf
      1  SELECT p.pid, s.sid, s.serial#, sq.sql_text
      2    FROM v$session s,
      3      v$process p,
      4      v$sql sq
      5    WHERE s.paddr = p.addr
      6*   AND sq.address = s.sql_address
    SQL> /
           PID        SID    SERIAL# SQL_TEXT
            37        128          2 BEGIN EMD_NOTIFICATION.QUEUE_READY(:1, :
                                     2, :3); END;
            19        149       4566 SELECT p.pid, s.sid, s.serial#, sq.sql_t
                                     ext   FROM v$session s,     v$process p,
                                          v$sql sq   WHERE s.paddr = p.addr
                                      AND sq.address = s.sql_address
    SQL>Edited by: Łukasz Mastalerz on Feb 12, 2009 1:27 PM

  • How to find the related PI document from a material document

    Dear All experts,
        If I know the materil document number, how to find the related PI document?
    Thanks!
    Xinling

    Hello Xinling,
    You can extract the details from table MSEG.
    Regards
    Kalpana

  • How to find the number of entries in a master data table

    Hi Experts,
    I am trying to find the entries in 0CUSTOMER master data.
    BW>LISTCUBE>Data target: 0CUSTOMER and selected the fields that I need.
    I would like to know how to find the "number of entrees". I tried to run the SUM for a count field, but it is taking forever as there are huge number of records .

    Hi Dev,
    Go to the change/display mode of the info object (0CUSTOMER) in your case. Go to the Master data/Text tab. Here you will find the master data tables according to your settings (P orQ or X or Y). Double click on the table name and it will take you to the SE11 display. From there, you can check the number of records as you do in any transparent table.
    Hope this helps.
    Thanks and Regards
    Subray Hegde

  • How to find the Commitment cost for a PM order using tables ?

    Hello all ,
           How to find the Commitment cost for a given PM order using table  .
    Thanks and regards ,
    Prem.

    Issue got resolved

  • How to find the AK Region name from JSP

    I have the requirement to hide some of the fields/regions in Oracle Sales Online.
    To do that from AK Developer Region Name/Code and Region Item is required. How to find this Region Code.

    When you are on the webpage, right click and select "VIEW SOURCE". When the notepad opens up, find the string "TOP REGION". This will give the top region for that page. Query for this page in the AK Developer resp with "Define Regions". Then click on "Region Items". This will give all the Attribute Names and Nested Regions within the TOP REGION. You just have to dig into each one of 'em to find the one you need.

  • How to find the Web Dnpro component from the Source code ?

    Hi Gurus,
    Please help me to find out the WD Component Name from the Source Code?
    Regards
    Anil

    Hi Thomos,
    When i right clik on the screen i see the following line by line.
    -Back
    -forward
    -save background as
    -set as background
    -copy background
    -set as desktop item
    -select all
    -Paste
    -create shotcut
    -add to favorites
    -view source
    -encoding
    -print
    -refresh
    -export to microsoft excel
    -properties
    I have mentioned every thing i see when ever i right click on the screen.
    --Anil

  • How to find the Web AS Port from ABAP program

    Hi
    I have an ABAP program which passes an URL for a BSP page to the Alert Framework. While creating the URL I need to find out the Hostname and port number for the Web service for that server. Hostname comes from sy-host but I am not able to find the port number.
    Please help...
    Thanks in advance

    Hi,
    consider this little code snippet:
    data:  l_urls       type tihttpurls2.
    call method cl_http_server=>get_extension_info
       EXPORTING
        extension_class = 'cl_http_ext_bsp'                  
       IMPORTING
            urls            = l_urls.
    l_urls contains a table of configured ports. maybe that helps.
    regards, Ulli

  • How to find the creation date of a column in a table?

    Hi,
    i scroll all the view and table of the Oracle RDBMS catalog and i didn't find how i can find when a column has been added to a table.
    Is there a way i can find this info?
    The column added is not the same date tehn the date of the table creation or the analyse column.
    Thanks

    Hi,
    Something like this
    select table_name, created from user_objects where object_type = 'TABLE'Regards
    Anurag Tibrewal
    Oops: I did not see the requirement correctly. If auditing is not the option for you then logminer (if archive is present) else no other option i can think of.
    Edited by: Anurag Tibrewal on Oct 6, 2009 8:37 PM

  • Oracle tuning: How to find percentage rows being accessed from a table

    Oracle recommends that full table scan on a large table is good if the number of rows being accessed is more than 20%. My question is how to I find out how many rows of the table is being accessed if I have a complex SQL which involves 10 other tables.

    Hi,
    there are two approaches to SQL tuning. One is to list all things that could possibly be wrong with the database, search for typical solutions, and try them all one by one.
    The other is to find out what is taking all the time and work on it.
    As I'm sure you've already figured by now, the first approach is unreliable, error-prone, inefficient. In one word, wrong. The only reason it's still around is because:
    1) 10 years ago Oracle diagnostic tools weren't as advanced as they are now,
    2) some people never learn
    3) there's no way to stop these people from writing stupid things on the internet.
    So forget all about these unreset HWM, low ratios and other dreadful things that could be wrong with your database code, and focus on things that are wrong. Follow instructions in this forum's FAQ to find the root cause of the problem (if you have questions along the way, post them here, we'd be happy to help). If this leads you to HWM, then fix it. If it doesn't, don't waste your time on it.
    Best regards,
    Nikolay

Maybe you are looking for

  • Could not resolve host (nil); Unknown error

    Trying to install arch linux into virtualbox... I got it to boot and everything, got my internet set up (I think), installed virtualbox guest stuff, and then had to reboot. I try to do sudo pacman -S xorg-twm xorg-xclock xterm so that I can test X be

  • Drag and drop not correct size

    In PSE 12 when I drag and drop a 4.8 in square image onto a 8.5x11 blank page (Both at 300 ppi) the 4.8 image does not show as small, it fills in the larger page.  What am I doing wrong? HELP!

  • Executing a BDC Session using a Function Module from a Custom Z-Report

    Hello,           I have a requirement where I need to Create a BDC Session for the given Transaction Code. But instead of executing the Session from SM35 manually, I need to Execute the Session Immediately from my Custom Z-Report itself.          Is

  • Dispatch Action

    Hi how to use DispatchAction in struts

  • Need automated/hands-off deployment for VO extension

    Hello, I have created a VO extension. I only changed the query in an LOV, so I only need to promote the jpx and xml files. I have successfully promoted the xml file (moved it to the custom directory) and imported the JPX file with JPX importer. Now w