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...


Given an employee table, how would you find out the second
highest salary?

Answers were Sorted based on User's Feedback



Given an employee table, how would you find out the second highest salary?..

Answer / sowjanya

Select * from emp where sal=(select Max(sal) from emp where
sal<(select Max(Sal) from emp)

Is This Answer Correct ?    7 Yes 0 No

Given an employee table, how would you find out the second highest salary?..

Answer / trived

select * from emp
where n-1 = (select count(*) from emp e
where emp.salary<e.salary)

in place of n-1 you can keep zero for first hight salary
and 1 for second hightest salary.....etc

Is This Answer Correct ?    9 Yes 3 No

Given an employee table, how would you find out the second highest salary?..

Answer / rony sunny

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

Is This Answer Correct ?    5 Yes 1 No

Given an employee table, how would you find out the second highest salary?..

Answer / ravikumar

select ename,esal from
(select ename,esal from hsal
order by esal desc)
where rownum <=2

Is This Answer Correct ?    2 Yes 0 No

Given an employee table, how would you find out the second highest salary?..

Answer / balindra sahani

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

Is This Answer Correct ?    2 Yes 0 No

Given an employee table, how would you find out the second highest salary?..

Answer / karna

select top 1 a.salary,* from emp a
where a.salary not in(select top (n-1) b.salary from emp b)

here n is the Nth values:if you want secong highest: keep n
as 2 so the query will become

select top 1 a.salary,* from emp a
where a.salary not in(select top 1 b.salary from emp b)

Is This Answer Correct ?    3 Yes 2 No

Given an employee table, how would you find out the second highest salary?..

Answer / balindra sahani

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

Is This Answer Correct ?    1 Yes 0 No

Given an employee table, how would you find out the second highest salary?..

Answer / mithilesh mishra

Select Max(sal) from emp where sal not in (select max(sal)
from emp)

Is This Answer Correct ?    1 Yes 0 No

Given an employee table, how would you find out the second highest salary?..

Answer / vivek mohan singh

select salary from tablename order by salary desc limit 1,1;

Is This Answer Correct ?    2 Yes 3 No

Post New Answer

More DB Development Interview Questions

agregator gives one to many records or many to one record

1 Answers   IBM,


Explain the rollup operator?

0 Answers  


How to generate OIDS

0 Answers  


In which database can extended stored procedures be added?

0 Answers  


Hi my program is accesing data from two db2 databases.what is the bind card for this program to genarate plan? how to specify the two owners and two qualifiers in bind card

0 Answers   TCS,


What is the system function to get the current user's user id?

4 Answers  


You have two tables with a one to many join based on a field named id. You need to find records in the parent table that are not represented in the child table. how would you accomplish this?

0 Answers  


Explain about relational database management systems?

0 Answers  


Given an employee table, how would you find out the second highest salary?

9 Answers  


How you can make a parameterized view?

0 Answers  


How long can an error message be in raiseerror function?

0 Answers  


There is a trigger defined for INSERT operations on a table, in an OLTP system. The trigger is written to instantiate a COM object and pass the newly insterted rows to it for some custom processing. What do you think of this implementation? Can this be implemented better?

0 Answers  


Categories