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 / sudhakar tripathi

select Max(salary) "2nd_Heigh_sal" from employees where
(salary < select Max(salary) from employees);

Is This Answer Correct ?    0 Yes 1 No

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

Answer / ajeshanath

select max(salary) from emp where salary not in
(select max(salary) from emp)

Is This Answer Correct ?    0 Yes 1 No

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

Answer / amy

select TOP salary from employee where salary in( select TOP 2 salary from employee order by salary desc) order by salary asc

Is This Answer Correct ?    0 Yes 1 No

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

Answer / praveen kumar.dandu

select a.sal,rank from(select sal,rank() over (order by sal
desc))a where rank=&n




<Here after printing the ranks we can retrieve we can
retreive what ever the rank we want>

Is This Answer Correct ?    2 Yes 4 No

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

Answer / sunil

select top 1 * from emp where sal not in (select max(sal)
from emp) order by sal desc

Is This Answer Correct ?    1 Yes 3 No

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

Answer / gokul

In MySQL, this query will be easier to find 2nd highest
salary and to fetch all the fields from a table.

select * from emp where sal not in (select max(sal)
from emp) order by sal desc limit 1

Is This Answer Correct ?    1 Yes 3 No

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

Answer / lakshmi

select * from (select *,rowcount()over (orderby emp desc)as
rank from emp)b where rank=2

Is This Answer Correct ?    0 Yes 2 No

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

Answer / abhijit banik

To get the n-th highest salary from employee table in oracle-10g
--------------------------------------------------------------
select min(salary)
from
(
select rownum rn, salary
from
( select distinct(salary) from employee order by salary desc )
)
where rn<=&n+1

Is This Answer Correct ?    1 Yes 3 No

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

Answer / arvind

rameshwari r u idiot dont u know the ans for this simple
que... worst fellow

Is This Answer Correct ?    1 Yes 4 No

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

Answer / sreekanth

SELECT MIN(SAL)
FROM(SELECT distinct SAL FROM EMP
ORDER BY SAL DESC)
WHERE ROWNUM <= :N
where N is the Nth highest salary u want

Is This Answer Correct ?    18 Yes 22 No

Post New Answer

More SQL PLSQL Interview Questions

Given two tables Student(SID, Name, Course) and Level(SID, level) write the SQL statement to get the name and SID of the student who are taking course = 3 and at freshman level.

9 Answers   Oracle,


What is the difference between CHAR and VARCHAR2? If VARCHAR2 serves the uses of CHAR why CHAR is still used and not been discarded yet?

9 Answers   Oracle,


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 is error ora-12154: tns:could not resolve the connect identifier specified?

0 Answers  


Explain architecture of sql server notification services?

0 Answers  


If we update a complex view, is base table will get update ?

2 Answers   Ardee Technologies, HCL,


Why cannot I use bind variables in ddl/scl statements in dynamic sql?

0 Answers  


What is a rank in sql?

0 Answers  


If a cursor is open, how can we find in a pl/sql block?

0 Answers  


What are the default Oracle triggers??

3 Answers   CGI, Tech Mahindra,


What is the use of sqlerrd 3?

0 Answers  


How many types of triggers are there in pl sql?

0 Answers  


Categories