How to get two top salaries from each department
select st.staff_name,st.dept_code,
st.staff_sal
from staff_master st
where staff_code in ((select staff_code
from staff_master s
where staff_sal=(select max(staff_sal) from staff_master where dept_code=st.dept_code))
union
select staff_code from staff_master st where staff_sal=
(select max(staff_sal) from staff_master where dept_code=st.dept_code and staff_sal < (select max(staff_sal) from staff_master where dept_code=st.dept_code)))
order by st.dept_code;
You can use RANK, DENSE_RANK or even ROW_NUMBER based on your need. Below is an example using DENSE_RANK. I have used EMP table available in SCOTT schema.
SQL> select * from emp order by deptno, sal desc;
EMPNO ENAME JOB MGR HIREDATE SAL COM DEPTNO ID
7782 CLARK MANAGER 7839 09-JUN-13 12450 0 10
7839 KING PRESIDENT 17-NOV-13 5000 0 10
7788 SCOTT ANALYST 7566 19-APR-87 13000 0 20
7369 SMITH CLERK 7902 02-APR-13 12975 0 20
7566 JONES MANAGER 7839 02-APR-13 12975 0 20
7876 ADAMS CLERK 7788 23-MAY-87 11101 0 20
7698 BLAKE MANAGER 7839 01-MAY-13 12850 0 30
7499 ALLEN SALESMAN 7698 20-FEB-13 11600 300 30
7844 TURNER SALESMAN 7698 08-SEP-13 11500 0 30
7521 WARD SALESMAN 7698 22-FEB-13 11250 500 30
7654 MARTIN SALESMAN 7698 28-SEP-13 11250 1400 30
11 rows selected.
SQL> select *
2 from (
3 select e.*
4 , dense_rank() over(partition by deptno order by sal desc) emp_rank
5 from emp e
6 )
7 where emp_rank <= 2;
EMPNO ENAME JOB MGR HIREDATE SAL COM DEPTNO ID EMP_RANK
7782 CLARK MANAGER 7839 09-JUN-13 12450 0 10 1
7839 KING PRESIDENT 17-NOV-13 5000 0 10 2
7788 SCOTT ANALYST 7566 19-APR-87 13000 0 20 1
7369 SMITH CLERK 7902 02-APR-13 12975 0 20 2
7566 JONES MANAGER 7839 02-APR-13 12975 0 20 2
7698 BLAKE MANAGER 7839 01-MAY-13 12850 0 30 1
7499 ALLEN SALESMAN 7698 20-FEB-13 11600 300 30 2
7 rows selected.
SQL>
Similar Messages
-
How to get 3 maximum salaries from emp
Hello,
Dear fellows how can we get 3 maximum salaries from emp
table in SQL.
plz reply me soon
thanksDoes it work ?
13:18:31 SQL> select * from my_tab1;
A B
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
8 rows selected.
13:19:24 SQL> ed
Wrote file afiedt.buf
1 SELECT UNIQUE a FROM my_tab1 WHERE a>=
2 (SELECT MAX(a) FROM my_tab1 WHERE a<
3 (SELECT MAX(a) FROM my_tab1 WHERE a <
4* (SELECT MAX(a) FROM my_tab1)))
13:19:34 SQL> /
no rows selected -
How to get the TOP MAT from a component material of BOM list?
I only kown a sub material of a BOM Llist & not sure its level in the TOP MAT's BOM.
How can i get the TOP MAT of this sub material?
Any BAPI or Function?
TKS a million~~~HI .. in my view you should ask your ABAP to help you with a small program to solve your purpose, i am not aware of any system available t-code/ program ..... hence this is what we also did at client place.
-
How to get all the values from the dropdown menu
How to get all the values from the dropdown menu
I need to be able to extract all values from the dropdown menu; I know how to get all those values as a string, but I need to be able to access each item; (the value in a dropdown menu will change dynamically)
How do I get number of item is selection dropdown?
How do I extract a ?name? for each value, one by one?
How do I change a selection by referring to particular index of the item in a dropdown menu?
Here is the Path to dropdown menu that I'm trying to access (form contains number of similar dropdowns)
RSWApp.om.GetElementByPath "window(index=0).form(id=""aspnetForm"" | action=""advancedsearch.aspx"" | index=0).formelement[SELECT](name=""ctl00$MainContent$hardwareBrand"" | id=""ctl00_MainContent_hardwareBrand"" | index=16)", element
Message was edited by: testtestThe findElement method allows various attributes to be used to search. Take the following two examples for the element below:
<Select Name=ProdType ID=testProd>
</Select>
I can find the element based on its name or any other attribute, I just need to specify what I am looking for. To find it by name I would do the following:
Set x = RSWApp.om.FindElement("ProdType","SELECT","Name")
If I want to search by id I could do the following:
Set x = RSWApp.om.FindElement("testProd","SELECT","ID")
Usually you will use whatever is available. Since the select element has no name or ID on the Empirix home page, I used the onChange attribute. You can use any attribute as long as you specify which one you are using (last argument in these examples)
You can use the FindElement to grab links, text boxes, etc.
The next example grabs from a link on a page
Home
Set x = RSWApp.om.FindElement("Home","A","innerText")
I hope this helps clear it up. -
In EmP tabel, empname ,deptno ,sal.In Dept column there are three departments they got 20 employees each ,how to get the top
5 highest sal from each departmentYou're in the wrong forum (this one is for issues with the SQL Developer tool). You'll get more answers in the SQL And PL/SQL forum...
Have fun,
K. -
How to get windows username printed on each page irrespective of application? we have HP CM6030F.
Hi,
Normally, you will receive a Windows Azure Pass from your local Windows Azure team. Please try to contact your local Windows Azure contact (http://support.microsoft.com/gp/customer-service-phone-numbers?wa=wsignin1.0
Also, you could see this page
http://www.windowsazurepass.com/AzureU/AcademicFAQ and apply the free trial azure via (http://www.windowsazurepass.com/AzureU/).
Q: I am a student. Can I apply for a pass?
A: Windows Azure Educator Grants are only for valid faculty. If your faculty has been awarded a Windows Azure Educator Grant, you will be able to get a pass through him/her for you coursework. If you are interested in learning more about Windows Azure,
we encourage you to share these Educator Grants with your faculty or sign up for the FREE 3-month trial offer.
Regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
How to get two empty columns in reporting?
Hi Experts,
How to get Two empty columns in a report, i have taken a formula and i have given '=0' in the formula box after executing the query that two columns containing zero's, but i don't want zero's, i want to display empty columns.
pl help to do this,
thanks & regards
venaktHi
In the Query designer go to Properties and Select Active n Zero Supression
also select Supress Zeros from the drop down.
Regards
M.A -
How to get the Database type from weblogic Db connection
I want to use database version control in my application . that means different database type use different Sql Statement. Such as in weblogic7.0 if I create SqlServer JDBC pool then I will use some special Sqlserver sql Statement . such as some join statement. If I create Oralce JDBC pool then I have to use different Sql statement . because these two database support different Sql statement.
What my question is how to get the database type from the connection.For a normal jdbc driver you can use
Connection.getMetaData()
To get the meta data, in particular the getDatabase...() methods.
That might or might not work.
However, at the very least in the server you have access to the weblogic properties so you can parse the pool property to figure it out. -
Why do I get two different results from the same coefficients?
I am getting two different results from the Polynomial Evaluation function.
For the first one, I am getting the coefficients from a Polynomial Fit function. I feed the coefficients from the Fit function into the Poly Eval function and get the correct result of 12.8582 when I evaluate 49940.
For the second one, I create constant array of the SAME values that were returned from the Polynomial Fit function (i typed them in). However, I am getting an incorrect result of -120.7913 when I feed the constant array into the Poly Eval function when I evauate 49940.
How can this happen when I am using the same array values?
Attached is an image of what I am explaining.
Solved!
Go to Solution.
Attachments:
polynomial_evaluation.jpg 213 KBHi Altran,
are you sure about using the "same" coefficients?
Did you compare them? Did you (atleast) set the display properties to 17 significant digits?
Please attach a VI instead of a picture...
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome -
Need to retrieve two highest salaries from table like that 3highest salarie
Hi,
I created emp table.I want to retrieview two highest salaries from emp table.
and also first three highest salaries...Pls can anyone suggest me..i am new to oracle.
ThanksWelcome to the forum.
What you're looking for is the so called 'Top-N query'.
It is explained by Tom Kyte in these articles:
http://www.oracle.com/technetwork/issue-archive/2007/07-jan/o17asktom-093877.html
http://www.oracle.com/technetwork/issue-archive/2006/06-sep/o56asktom-086197.html
And Tim Hall also has an article about it:
http://www.oracle-base.com/articles/misc/TopNQueries.php
Edited by: hoek on Feb 20, 2012 9:00 PM -
How to get the return values from a web page
Hi all :
how to get the return values from a web page ? I mean how pass values betwen webflow and web page ?
thank you very much
Edited by: jingying Sony on Apr 15, 2010 6:15 AM
Edited by: jingying Sony on Apr 15, 2010 6:18 AMHi,
What kind of web page do you have? Do you have possibility to for example make RFCs? Then you could trigger events (with parameters that could "return" the values) and the workflow could react to those events. For example your task can have terminating events.
Regards,
Karri -
How to get warranty service claim from nokia c5-03...
how to get warranty service claim from nokia c5-03 in india because i have problem with nokia c5-03 I Purchase 2 week ago a new nokia c5-03 but from day 1 i facing same problem like 1) app close itself 2) internet browse close if any thing is downloading or downloading over 3) memory full always then i should reboot the phone then it work. 4) ovi map is open it shows memory full close the app So kindly help me how to get warranty service claim from nokia c5-03 in india i am unhappy with nokia c5-03
Solved!
Go to Solution.i updated software also but the same problem cont... I want to know that nokia will give back money or exchange for other new mobile
-
For some reason the system is telling me my birth date is wrong when it's not and it won't let me proceed to reset my password. Can someone tell me how to get a "real" person from tech on line?
contact itunes support
-
How to get the current week from sysdate?
Hi sir,
i want to know how to get the current week from sysdate?
thanksHi Nicolas
It seems you like to check my post and also make commend ;) thanks for your attention
Have you ever read the posts above and given solutions ?Yes, I did
Have you read the docs ? Yes, I checked
What's the added value here ?Did youYou shared doc with solution(long one), I shared short one which point same solution(Check what Joel posted)..So what is benefit, As you can guess oracle docs are sometimes become so complicated as specialy for beginner...(At least it was like that for me and Belive me somedocs are still sooo complicated even for oracle coworkers ) But for you I dont know ;)
=> Why writting the PS in bold ?Why.. Let me think... Ohh Maybe I am looking some questions(many) and even user get answer they should not changed status so I am reading some posts and try to get problem and loosing time..
So I am putting that PS wiht BOLD because I dont wanna lose time my friend ;) Because While I am trying to help ppl here In same time I am trying to giving support to my customer prod systems. Which mean time is very important for me...
Hope my answer could satisfy you..
One important PS for you.. You may not like my posts (or someone) but my friend I become tired to read&answer and make commend to on your comment which is about my posts.
I am not newbie in forum(At least I fell like that) and I belive I know how I should make post..
Thank you
Regards
Helios -
How to get the selection parameters from logical database into one of the t
Hi Sap ABAP Champians,
How to get the selection parameters from logical database into one of the tab in the tabstrip selection-screen.
Please help me for this
Thanks
BasuHi
Thanks, that will work, but then I'll have to insert code into all my reports.
I can see that "Application Server Control Console" is able to rerun a report.
This must mean that the Report Server has access to the runtime parameters.
But how?
Cheers
Nils Peter
Maybe you are looking for
-
Mac OS X 10.6.6(SnowLeopard)とAcrobat Pro 9(9.3.0)にて Adobe Acrobat 9をインストールすると 自動的にシステム環境設定の中の「プリンタとファックス」上に 「Adobe PDF 9.0」が表示されるそうですが.表示されません. また.プリンタの追加(+)をクリックしても. 名前が表示されないので.選択・追加することが出来ません. Acrobatのアンインストール・再インストールなどは試みたのですがダメでした. なにか表示させるための解決
-
Hi! I just can't get WLS6.0 to use new versions of XALAN and XERCES. I keep getting errors that are obviously because Weblogic is loading an older version of XALAN before my app ever gets loaded, and as a result I'm having trouble with <xsl:param> an
-
Hello, I'm operating on a large table with a few million of records using SAP JPA running on AS Java 7.3.1 and Oracle 11g. While analyzing a performance issue, I came across a DB trace that led me to think that the setMaxResults() method on Query obj
-
Cisco ISE migration from VM to SNS 3415 Appliance
HI Experts, My customer is running a ISE VM ( os is 1.1.1 ) with base license used only for guest authentication . As per the requirement we need to migrate the existing setup to the ISE hardware (1.2 ). Can anyone please help me in the best way t
-
Will iPhoto '09 work with Lion?
Will iPhoto '09 work with Lion? Since I upgraded to Lion when I open a Facebook album in iPhoto I get the message "An error occurred with the publication of (album name)". The album was submitted successfully long ago. One of a few new quirks since t