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


Write a query to get 2nd maximum salary in an employee table ?

Answers were Sorted based on User's Feedback



Write a query to get 2nd maximum salary in an employee table ?..

Answer / sandeep

select top(1) a.salary
from

(
select top(2)sal
from
employee
order by salary desc
)a
order by a.salary asc

Is This Answer Correct ?    1 Yes 0 No

Write a query to get 2nd maximum salary in an employee table ?..

Answer / mark berlin.

REM solution #1:
select * from(
select distinct nvl(salary,-1) as sal
from employees
where nvl(salary,-1) < (select max(nvl(salary,-1)) from
employees)
order by nvl(salary,-1) desc)
where rownum=1;
REM Solution #2
select * from (
select distinct salary from employees
order by salary
desc
)
where rownum < 3
minus
select * from (
select distinct salary from employees
order by salary
desc
)
where rownum =1;

Is This Answer Correct ?    1 Yes 0 No

Write a query to get 2nd maximum salary in an employee table ?..

Answer / sushant hole

select max(salary) from employees where salary<(select max(salary) from
employees);

Is This Answer Correct ?    1 Yes 0 No

Write a query to get 2nd maximum salary in an employee table ?..

Answer / boby

select max(MAXI) from
(SELECT max(slno) AS MAXI FROM EMPLOYEE WHERE slno not IN(SELECT max(slno) FROM EMPLOYEE )
GROUP BY slno)a

Is This Answer Correct ?    1 Yes 0 No

Write a query to get 2nd maximum salary in an employee table ?..

Answer / naresh

select sal from emp e where 2= (select count(distntsal) from
emp y where e.sal<=y.sal);

Is This Answer Correct ?    1 Yes 0 No

Write a query to get 2nd maximum salary in an employee table ?..

Answer / neha singh

select min(sal)
from
(select sal from
(select sal from emp
order by sal desc)
where rownum<=2)

Is This Answer Correct ?    1 Yes 0 No

Write a query to get 2nd maximum salary in an employee table ?..

Answer / baburav zore

select max(sal) from employee where sal<(select sal from employee);

Is This Answer Correct ?    1 Yes 0 No

Write a query to get 2nd maximum salary in an employee table ?..

Answer / akshay

Select ename, eno, sal, rownum
from (select ename, eno, sal from emp order by sal desc)
where rownum = 2;

Is This Answer Correct ?    7 Yes 7 No

Write a query to get 2nd maximum salary in an employee table ?..

Answer / ahmad

Select Max(VacationHours) "MVacHrs"
from HumanResourcesEmployee
where VacationHours not in (Select Max(VacationHours)
from HumanResourcesEmployee)

Is This Answer Correct ?    2 Yes 2 No

Write a query to get 2nd maximum salary in an employee table ?..

Answer / google

Select min(sal) from emp where sal in (
select top 3 sal from emp
order by sal desc )

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

Can we perform dml in function?

0 Answers  


Cite the differences between execution of triggers and stored procedures?

0 Answers  


how to rename an existing column in a table? : Sql dba

0 Answers  


How to pronounce postgresql?

0 Answers  


Which column in the user.triggers data dictionary view shows that the trigger is a pl/sql trigger?

0 Answers  


What are operators available in sql?

0 Answers  


what is overloading procedure or overloading function ?

3 Answers   Genpact,


Why we use stored procedure instead of query?

0 Answers  


Does execute immediate commit?

0 Answers  


What is difference between % ROWTYPE and TYPE RECORD ?

2 Answers  


What are the events on which a database trigger can be based?

0 Answers  


what is the output of this query selet * from employee where 1=2 ??

11 Answers  


Categories