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 / priya

select rownum,empno,sal from (select
rownum,empno,sal from emp order by sal desc) group
by rownum,empno,sal having rownum=2;


This will clearly work.............

Is This Answer Correct ?    6 Yes 3 No

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

Answer / nitika

SELECT MAX(SAL) FROM EMPLOYEE WHERE SAL<(SELECT MAX(SAL)
FROM EMPLOYEE);

Is This Answer Correct ?    4 Yes 1 No

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

Answer / hasnain hameed

select max(salary)
from emp
where salary < (select max(salary) from emp)
order by salary desc;





i think this is correct answer all of above because it take
less time to execute. retrive the answer quickly.

Is This Answer Correct ?    6 Yes 4 No

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

Answer / kirti

Very simple answer: Arrange the top two salaries in
decending order. Select the mininum salary.

Select min(salary) from Employee where salary in(select top
2 salary from employee order by salary desc)

Is This Answer Correct ?    2 Yes 0 No

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

Answer / anupam274

use AdventureWorks

select * from HumanResources.EmployeePayHistory e where
2 = (select count(distinct Rate) from
HumanResources.EmployeePayHistory where e.Rate<=Rate)

select * from HumanResources.EmployeePayHistory e where
4 >(select count(distinct Rate) from
HumanResources.EmployeePayHistory where e.Rate<=Rate)

Is This Answer Correct ?    2 Yes 0 No

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

Answer / malli

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

Is This Answer Correct ?    2 Yes 0 No

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

Answer / gaurav mishra

The answer query is......

Select max(sal) from emp a where (&N-1) in(select count
(distinct(b.sal)) from emp b where a.sal<b.sal);

Is This Answer Correct ?    5 Yes 4 No

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

Answer / mallikarjuna

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

Is This Answer Correct ?    1 Yes 0 No

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

Answer / sanjib b

select last_name,salary from employees where salary =
(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 / sandeep

select top(1) a.name
from

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

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

What is on delete restrict?

0 Answers  


what is a relationship and what are they? : Sql dba

0 Answers  


how can we replace the particular column value of a resulted set of executed query? I mean write down a sql query to chane the particular column's value of a resulted set of executed query

3 Answers  


What is the use of function "module procedure" in pl/sql?

0 Answers  


What is the difference between microsoft access and sql server?

0 Answers  


What is sql*loader and what is it used for?

0 Answers  


cursor types? explain with example programs?

1 Answers   HP,


Explain what is a column in a table?

0 Answers  


what is 'mysqladmin' in mysql? : Sql dba

0 Answers  


What is Histogram?

0 Answers   NIIT,


How many clustered indexes can you have?

0 Answers  


need to split a string into seperate values. eg. col1 col2 ---------- 100 - 'a,b,c' 200 - 'a,x,b,d,e' 300 - 'c' result: value count ------------- a - 2 b - 1 c - 2 etc.

1 Answers  


Categories