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 / nagarjuna.reddy

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

Is This Answer Correct ?    0 Yes 0 No

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

Answer / sandip

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

I don't think this will work correct me if i am
wrong.Correct one is-------

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

Is This Answer Correct ?    0 Yes 0 No

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

Answer / sandip

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

The correct one is.......

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

Is This Answer Correct ?    0 Yes 0 No

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

Answer / pramod majhi

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

Is This Answer Correct ?    0 Yes 0 No

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

Answer / srinivas

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

Is This Answer Correct ?    0 Yes 0 No

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

Answer / sushma

SELECT * from
(SELECT * FROM emp ORDER BY sal DESC)
WHERE rownum <= 2
MINUS
SELECT * from
(SELECT * FROM emp ORDER BY sal DESC)
WHERE rownum < 2

Is This Answer Correct ?    0 Yes 0 No

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

Answer / debasish sinha

select ename,sal,deptno
from emp
where sal =
(
select max(sal)
from emp
where level=2
connect by prior sal>sal
group by level
)

Is This Answer Correct ?    0 Yes 0 No

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

Answer / veera

SELECT * FROM EMP A WHERE &N-1=(SELECT COUNT(DISTINCT SAL) FROM EMP B WHERE A.SAL<B.SAL) ORDER BY SAL

Pass Paramenter :2..it will give the 2nd maximum salary

Is This Answer Correct ?    0 Yes 0 No

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

Answer / lalit raghuvanshi

I got the solution:
Multiple Sql server queries to get second,third,fourth or nth highest/maximum salary from employee table
http://www.webcodeexpert.com/2014/08/sql-server-query-to-get.html

Is This Answer Correct ?    0 Yes 0 No

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

Answer / ashish jain

select Salary from
(
select salary,ROW_NUMBER() over (order by salary desc) as rownum from Emp group by salary) temp
where rownum=2

Note :It can be used to get any highest salary, just use where rownum=nth salary

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

What is sql engine in oracle?

0 Answers  


while loading data into database how can u skip header and footer records in sql*loader

1 Answers   Oracle,


What is spool?

0 Answers  


What is a bitmap index?

4 Answers   Choice Solutions, Infosys,


what is rollback? : Sql dba

0 Answers  


If a procedure within a package is invalidated whether the entire package will be invalid and has to be recompiled again?

2 Answers   IBM, TCS,


wht is the difference between truncat,drop in sqlserver wht is the difference between function and stored procedure

3 Answers   Apollo,


Is sql harder than python?

0 Answers  


How can we overcome recursive triggers in SQL?

1 Answers   iFlex,


What is the example of procedure?

0 Answers  


Can we insert data into view?

0 Answers  


What is the difference between rename and alias?

0 Answers  


Categories