Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how to find the second highest salary from emp table?

Answers were Sorted based on User's Feedback



how to find the second highest salary from emp table?..

Answer / dev anand s

select salary from (
select salary, dense_rank() over(order by salary desc) rank from emp) where rank=2;

Is This Answer Correct ?    0 Yes 0 No

how to find the second highest salary from emp table?..

Answer / rajkishore bagwan

simplest method ----
select salary
from employees
order by salary desc
offset n-1 rows fetch next 1 rows only
(replace n with any number it will give you the nth highest salary)

Is This Answer Correct ?    0 Yes 0 No

how to find the second highest salary from emp table?..

Answer / hitesh

select top 1 salary from t1 where salary in(select top 2
salary from t1 order by salary desc)order by salary asc

Is This Answer Correct ?    2 Yes 3 No

how to find the second highest salary from emp table?..

Answer / sabari

select max(salary ) from emp where salary<(select max
(salary)from emp )

Is This Answer Correct ?    1 Yes 2 No

how to find the second highest salary from emp table?..

Answer / sumit sharma

select sal from (select distinct(sal) from emp where sal is
NOT NULL order by sal dsc) where rownum = 2

Is This Answer Correct ?    1 Yes 2 No

how to find the second highest salary from emp table?..

Answer / priya

select sal from emp where sal <(select max(sal) from emo)
and rownum<2 order by desc


though rownum which is a pseudo column can be used for
comparisions with relational operators like > or < ,>=, <=
but equalto = may not work in most of the cases..
similarly rowid also.

Is This Answer Correct ?    0 Yes 1 No

how to find the second highest salary from emp table?..

Answer / nitin umale

SELECT *
FROM employees
WHERE salary =
( SELECT MIN ( r.salary)
FROM ( SELECT salary
FROM ( SELECT DISTINCT salary
FROM employees
ORDER BY NVL(salary,0) DESC
)
WHERE rownum<3) r
);

Is This Answer Correct ?    0 Yes 1 No

how to find the second highest salary from emp table?..

Answer / abhay

select max(sal) from emp where sal< (select max(sal) from
emp)

Is This Answer Correct ?    0 Yes 1 No

how to find the second highest salary from emp table?..

Answer / ravi

SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP n salary
FROM employee
ORDER BY salary DESC) a
ORDER BY salary

where n is the nth highest salary

Is This Answer Correct ?    0 Yes 1 No

how to find the second highest salary from emp table?..

Answer / dinesh

select * from emp order by sal desc limit 1,1

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More SQL PLSQL Interview Questions

Hi all, i have a table as follows empid empname mgrid deptid 1 a 3 4 2 b 1 5 3 c 2 3 4 d 3 6 5 e 4 7 i want the output as empname mgrname a c b a c b d c e d

4 Answers  


In a table i have columns A,B,C and i have a composite index on columns A,B if so will the following query uses index or not? SELECT sal,name FROM <table_name> WHERE A=<value> AND B=<value> AND C=<value>;

2 Answers   Mastek,


While inserting 10 rows using procedure, if 3rd entry is having some error, what will be the output? How u will handle that error?

8 Answers   iFlex,


what are date and time intervals? : Sql dba

0 Answers  


how to achieve this problem?i am having table with two colums like empno,gender. in gender column, i am having records male,female like that .my final output will be male female 5 6

4 Answers   Hexaware,


What is the requirement of self-join?

0 Answers  


what are %TYPE and %ROWTYPE? what is the difference?

7 Answers   ICICI, Saama Tech, Sail,


define sql delete statement ? : Sql dba

0 Answers  


Why are cursors used?

0 Answers  


Write the command to remove all players named sachin from the players table.

0 Answers  


Where not exists in sql?

0 Answers  


What is the use of time stamp in select statement?

1 Answers   TCS,


Categories