Write a query to find second highest salary of an employee.
Answers were Sorted based on User's Feedback
Answer / rajkumar mandala
select sal from
(select sal,(row_number() over (order by sal)) N from emp ) y where N= {value}
Replace {value} value with required highest value.
ie, 2 for 2nd highest
| Is This Answer Correct ? | 7 Yes | 3 No |
Answer / aj
select * from emp A where 1=(select count(*) from emp B
where A.SALARY < B.SALARY)
| Is This Answer Correct ? | 12 Yes | 9 No |
Answer / girase hitendrasing a.
select * from Employees where Salary in (select top 1
salary from (select distinct top 2 salary from employees
order by salary desc) order by salary asc)
| Is This Answer Correct ? | 5 Yes | 2 No |
Answer / bhaskar reddy thamma
SELECT DISTINCT (a.sal) FROM EMP A WHERE &N = (SELECT COUNT
(DISTINCT (b.sal)) FROM EMP B WHERE a.sal<=b.sal);
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / n.tejaswi
Select Empname
from emp LIMIT 2
orderby empsal;
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / khurram
The Simplest, easy, Understandable solution is
select max(sal) from emp where
sal not in
(select distinct Top 1 sal from emp order by sal desc)
Go Check Out for yourself
[replace "top 1" by "top 2" to get 3rd highest sal]
[replace "top 1" by "top 3" to get 4th highest sal] so on..
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / ujwlala
select max(salary) from employee where salary<>(select
max(salary) from emp)
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / satish
select e1.* from emp e1 where 1=(select count(distinct
e2.sal) from emp e2 where e2.sal>e1.sal)
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / ashutosh singh
select distinct(a.Sal) from emp a where &n=(select
count(distinct(b.Sal)) from emp b where b.Sal<a.Sal)
| Is This Answer Correct ? | 2 Yes | 1 No |
How you report bug in to bugzilla
Why do you want to keep this kind of information in a separate file and not directly in the code?
How could the web element attributes be inspected in order to use them in different locators?
I am surekha new commer for this site? I have some doubt's pls clarify it..... I finished my B.tech and S/w Testing Course Now iam searching for a job in Testing, I did not have any experience in real time projects. Any body can send me the sample Testcases,Srs,Matrix for Banking,ERP Projects etc.Here is my email id surekhai@yahoo.com
Why we use Junit and Jmeter? Suggest some sites where we can get more information on these two Tools?
which tools is the best in Automation
When do you prefer manual testing over automation testing?
What are the scripting languages used in WinRunner, LoadRunner, QTP, Test director, ClearQuest, Rational Robot? How do you decide which tool will be a best fit for your test enviorment?
How do you select the 2nd item in a List box or drop down through selenium RC (Java)
What is the Driver sheet??
IN AN APPLICATION HOW DO YOU IDENTIFY THE TASKS WHICH SHUD BE DONE MANUALLY AND WHICH SHUD BE AUTOMATED?
Tell us the line of code webdriver driver = new firefoxdriver();.?