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

Select top 2 sal from (select sal from emp order by sal
desc)

Is This Answer Correct ?    0 Yes 0 No

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

Answer / dsr

query:
======
select e.name,e.salary from emp e where &n =(select
count(distinct ee.salary) from emp ee where e.salary<=e.salary)

after run enter n value:

if 2 enter second max salary will come
if 3 enter third max salary will come.

otherwise, we can write below

select e.name,e.salary from emp e where 2 =(select
count(distinct ee.salary) from emp ee where e.salary<=e.salary)

Is This Answer Correct ?    0 Yes 0 No

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

Answer / nitin

SQL> select emp_sal from (select emp_sal from nitin order
by emp_sal desc) group by rownum,emp_sal
having rownum=2;

Is This Answer Correct ?    0 Yes 0 No

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

Answer / rahul thakur

select top 1 salary from emp where id not in (select top1 id from emp order by salary desc)order by salary desc.

Is This Answer Correct ?    0 Yes 0 No

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

Answer / mastan

select name,salary from (select salary from emp order by
salary desc)where rownum<2

Is This Answer Correct ?    1 Yes 1 No

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

Answer / jyotiprokash

Select * from emp e1 where 1=(select count(distinct sal) from emp e2 where e1.salary<e2.salary)

Is This Answer Correct ?    1 Yes 1 No

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

Answer / raja

first find third maximum
then it ll be very easy to find second maximum.. :)

Is This Answer Correct ?    0 Yes 0 No

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

Answer / em rao

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

Is This Answer Correct ?    2 Yes 2 No

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

Answer / kameshwar shukla(a.i.e.t l.k.o

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

Is This Answer Correct ?    0 Yes 0 No

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

Answer / khushbu

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

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

What is sql comments?

0 Answers  


How did you export data from database to excel file.

1 Answers   TCS,


What is AUTH_ID and AUTH_USER in pl/sql ?

0 Answers   INDUS,


Can we create foreign key without primary key?

0 Answers  


What is normalisation and its types?

0 Answers  


How does one load ebcdic data? : aql loader

0 Answers  


How do you display "13th of November, 17 days left for month end" without hardcoding the date.

3 Answers  


Can I create table without primary key?

0 Answers  


Is sql dba a good career? : SQL DBA

0 Answers  


what is the difference between implicit and explicit trigger

2 Answers   Tech Mahindra,


What are the different types of database management systems?

0 Answers  


There is a table, In one column it has implemented a index, but the index is disturbed by the regular dml statements.. but still we need to keep the index. how it is possible?

1 Answers   Cognizant,


Categories