Anybody can tell me, how do we find second largest emp
salary from emp table.. Thanks in advance ...
Answers were Sorted based on User's Feedback
Answer / raj
select max(sal) from emp where sal < (select max(sal) from
emp)
Is This Answer Correct ? | 31 Yes | 1 No |
Answer / selvaraj anna university coe
Oracle 10g Using : Find 2nd Highest Salary?
SELECT * FROM emp e WHERE 2=(SELECT COUNT(DISTINCT salary)
FROM emp x
WHERE x.salary >= e.salary);
Answer :
EMP_NO EMP_NAME SALARY
--------- ------------------------- ---------
107 SARABOOT 550000
Is This Answer Correct ? | 10 Yes | 1 No |
Answer / mahaboob
I would say that Raj has given the correct answer in general.
In most cases the interviewer restricts the parameter to be
written in the query as it might effect the performance.
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / amitkumar
Select TOP 1 salary from (select Distinct TOP 2 salary from
employee orderby salary desc)
Is This Answer Correct ? | 5 Yes | 2 No |
Answer / samad
Dear
here i am sending new ans u can give the value in parameter
SELECT SAL,NO FROM(
SELECT SAL ,ROWNUM NO FROM
(SELECT DISTINCT SAL FROM EMP ORDER BY SAL DESC)) WHERE NO=:N
Regards,
Samad
Is This Answer Correct ? | 5 Yes | 2 No |
Answer / hemalatha
Following is the query to find the nth maximum salary:
select * from emp
where sal=(select distinct(sal) from emp a
where &n=(select count(sal)from emp
where sal>=a.sal;))
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / keerthi
select(max(salary)
from employee
where sal>max salary&salary<max salary-1;
if you say no to my answer plz correct me.
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / apsar
select sal from (select sal,count(sal) over order by salary desc c)temp where temp.c=&n;
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / martin
select e.sal from emp e where &2>(select max(count{a.sal})
from emp a where a.sal > e.sal order by desc
)
Is This Answer Correct ? | 1 Yes | 4 No |
hi friends, I have a table A col as status|NUM and value as open |1 open |2 close |3 close |3 the O/P should be open|close 1 |3 2 |4
How to retrieve the count of updated rows?
Query to retrieve record for a many to many relationship ?
How to list all tables in your schema?
What happens if variable names collide with table/column names?
Explain 1st, 2nd, 3rd normalization form of data base
what are different types of deletes?
How to call a stored function in oracle?
HI Friends Myself Manoj,i am from bengaluru.i have 1 yr of exp in PLSQL but not upto the mark..now attending interviews but m not able to clear even 1 round..i have attended 3 interviews till today.purpose of writing this query is,i want to know the intreview topics that interviewer going to ask frequently,mainly SCENARIO based questions.IF anybody have any PLSQL projects please give it to me,it will helps me alot.Thanks for your patience.
Can I create users through internet explorer in oracle 10g?
How to run create database statement?
What is dual table oracle?