Write a query to find second highest salary of an employee.
Answers were Sorted based on User's Feedback
Answer / p
select ename from emp where esal=(select max(esal) from emp
where esal<(select max(esal) from emp));
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / satish
select e1.* from emp where 1=(select e2.sal from emp e2
where e2.sal>e1.sal)
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / kapil deep
SELECT * FROM (SELECT * FROM emp_t WHERE ROWNUM < 3 ORDER
BY salary) WHERE ROWNUM < 2
above query work fine for oracle.
Taking 3 as N give u 3-1=2 i.e 2nd highest
4-1=3 gives u 3rd highest
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / deepak falke
3rd highest sal from account :
SELECT TOP 1 Sal FROM account WHERE Sal IN
(SELECT distinct TOP 3 Sal FROM account ORDER BY Sal DESC)
order by sal
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / vidhya
select max(column name) from table_name where((select max
(column name) from table_name Order by salary Desc) set
difference (select max(column name))
Is This Answer Correct ? | 2 Yes | 5 No |
Answer / krishna kishore
SELECT TOP 1 Salary FROM Employee WHERE Salary IN
(SELECT TOP 2 Salary FROM Employee ORDER BY Salary DESC)
I think this would be the simplest way and high performance
query.
waiting for the comments !!!
Is This Answer Correct ? | 7 Yes | 11 No |
Answer / muralidhara(minchu)
Select * from epm A where &(n-1)=(select count(*) from emp
B where A.sal < B.sal);
Try this it will work,this will give nth salary ie if u
enter 2 this will give second highest sal
Is This Answer Correct ? | 13 Yes | 22 No |
Answer / sridhar
Its real simple. Suppose your employees are in a table
called by the same name, and the salaries in a column named
salaries). Lets See te case in which we want the 3 greatest
salaries. Then you Query:
SELECT employees.salary
FROM employees
ORDER BY employees.salary desc
LIMIT 3;
If you want the biggest 5 salaries, you put LIMIT 5, and so on….
Is This Answer Correct ? | 3 Yes | 16 No |
Answer / krishna
select sal from empa where 1=(select count of sal from emp
b)where a.sal<b.sal
Is This Answer Correct ? | 9 Yes | 25 No |
Answer / gokulapriya
select * from employee where salary < (select max(salary)
from employee)
(i have written as sub query)
is this right
Is This Answer Correct ? | 5 Yes | 31 No |
Hi I need the following information about JMeter 1) How many(max) threads(users) can hit the website using Jmeter? 2) How long(in hours) can we run Jmeter for stress test? (Is there any “Memory full” issue if we run for long time?) 3)What typeof sampler to use for clicking on the link?
Tell us the difference between assert and verify commands?
What is a framework and what are the frameworks available in rc?
what is the advantage and dis-advantages of using framework ?
Explain me what is testng and why is it better than junit?
How do you start Selenium RC?
why should I automate mysoftware testing?
Do you know how can we make one test method dependent on other using testng?
What are the phases in automation testing life cycle?
What types of scripting techniques for test automation do you know?
hi friends i got placed in accenture july stil i hav not recieved offer letter... 2 weeks b4 HR cllaed ask abt the location do u perfer.... stil i am waiting i jus wanted to know wat posotin is going if somebody knows pls help me
Describe some problem that you had with automating testing tool.