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

select * from (select sal,deptno from emp a where
sal in (select distinct(b.sal) from emp b
where a.deptno=b.deptno and rownum<4)
order by deptno,sal desc )
minus
select * from (select sal,deptno from emp a where
sal in (select distinct(b.sal) from emp b
where a.deptno=b.deptno and rownum<3)
order by deptno,sal desc )

Is This Answer Correct ?    0 Yes 0 No

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

Answer / praveenkumar

SELECT salary FROM EMPtable
WHERE salary NOT IN ( SELECT MAX(salary)
FROM EMPtable)
ORDER BY salary DESC
FETCH FIRST ROW ONLY
---
We have verified and its working
fine.

Is This Answer Correct ?    0 Yes 0 No

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

Answer / arun

select distinct (a.salary) from employees a
where &N = (select count (distinct(b.salary))
from employees b where a.salary <= b.salary);

Is This Answer Correct ?    0 Yes 0 No

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

Answer / manvar prajesh

select top 1 name,salary from emp where salary<(select
max(salary) from emp)order by salary desc

Is This Answer Correct ?    0 Yes 0 No

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

Answer / barochia dharmesh

You should use rank query with order by and give where your
search criteria.

Is This Answer Correct ?    0 Yes 0 No

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

Answer / vikas

select * from(select e.*,row_number() over (order by
e.salary desc)rn from Employee e)where rn between 1 and 2
order by rn

Is This Answer Correct ?    0 Yes 0 No

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

Answer / ankit khanijau

Select salary from emp
where MAX(Select salary from emp where salary != MAX(salary))

Is This Answer Correct ?    1 Yes 1 No

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

Answer / abir dutta

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

Is This Answer Correct ?    0 Yes 0 No

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

Answer / monika

Select salary from emp order by salary desc LIMIT 1,1;

Is This Answer Correct ?    2 Yes 2 No

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

Answer / bhoopendra vishwakarma

select salary max(salary) from emp limit1 offset1

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

Can you join views in sql?

0 Answers  


Why triggers are used?

0 Answers  


How to fetch alternate records from a table?

0 Answers  


how to eliminate null values in a column i.e table vlaues 1 2 3 NULL 3 4 1 5 NULL i want output like this 1 2 3 3 4 1 5 i dnt want to use nvl is null and i dnt want replace the NULL value with any value i.e nvl(col,o);

11 Answers   Satyam,


What is sql character function?

0 Answers  


Is it possible to pass parameters to triggers?

0 Answers  


Write a query to find five highest salaries from EMP table. (there is a column SALARY)

24 Answers   Cap Gemini, iNautix,


How do I remove sql developer from windows 10?

0 Answers  


What is offset and limit in sql?

0 Answers  


With out using count() function. How to the find total number of rows in a table?

6 Answers  


Can we commit inside a trigger?

0 Answers  


What is the difference between SQL and PLSQL

7 Answers   IBM,


Categories