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 / omkar hendre

select distinct(sal) from emp a where 2=(select count(distinct(sal)) from emp b where a.sal <=b.sal)

Is This Answer Correct ?    0 Yes 0 No

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

Answer / swapnil tikale

Select top 1 salary from (select distinct top 2 salary from employee order by salary desc) as sal order by salary ;

Is This Answer Correct ?    0 Yes 0 No

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

Answer / prem chhappesh

select max(salary) from emoplyee where salary not in(select max(salary) from employee)

Is This Answer Correct ?    0 Yes 0 No

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

Answer / tejasvita dhuri

select id,salary from (select id,salary,ROW_NUMBER()over (order by salary desc) as rowcol from emp)A
where A.rowcol=2

Is This Answer Correct ?    0 Yes 0 No

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

Answer / anita prasad

SELECT MIN(SAL) FROM (SELECT DISTINCT * FROM EMP ORDER BY DESC) WHERE ROWNUM<3;

Is This Answer Correct ?    0 Yes 0 No

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

Answer / satish

select rownum,employee_id,first_name,max(salary) from
employees
group by rownum,employee_id,first_name
having rownum<=2
order by rownum

Is This Answer Correct ?    5 Yes 6 No

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

Answer / ebnezer

that is a correct answer

Is This Answer Correct ?    3 Yes 4 No

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

Answer / deven

select top 1 salary from emp where salary <>(
select top 1 salary from emp order by salary desc) order by
salary desc

Is This Answer Correct ?    0 Yes 1 No

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

Answer / deepa

select min(salary) from (select salary from table_name order by salary desc) where rownum<3;

Is This Answer Correct ?    1 Yes 2 No

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

Answer / niladri saha

into my above solution,u can get whatever position u want,only by giving "n" at the place of "2" at row num. That the right way to write the query. That u can use in dynamically.
Thanks,
like if ur require ment to print empnames of having 3rd max salary,then put 3 at rownum.
Niladri Saha.

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More SQL PLSQL Interview Questions

What is record type in pl sql?

0 Answers  


Is it mandatory for the primary key to be given a value when a new record is inserted?

0 Answers  


Hello All, Could any well write a query for the following scenario. Account(table name) No Name Amount 1 ABCD 2000.00 2 DEFG -2000.00 3 GHIJ 3000.50 4 JKLM 4000.00 5 MNOP 6000.00 O/p Should be in this format No Name Credit Debit 1 ABCD 2000.00 0 2 DEFG 0 -2000.00 3 GHIJ 3000.50 4 JKLM 0 -4000.00 5 MNOP 6000.00 o could any one give appropriate query for this Thnks in Advance

5 Answers   Target,


type type_name is table of varchar2(30) index by binary_integer for the above type you have to create a identifier... like identifier_name type_name; for the above type you can use the below methods..like first , last , prior, next , delege..etc...like this.. if you create a cursor...like cursor cursor_name is select * from scott.emp; is there any methods like above to use prior, fist , last , next , trim ,etc...

1 Answers   Satyam,


What is a sql driver?

0 Answers  


What is compilation error in pl sql?

0 Answers  


Is sql a oracle?

0 Answers  


Is primary key clustered or nonclustered?

0 Answers  


What do you mean by table in sql?

0 Answers  


What is the best partition size for windows 10?

0 Answers  


Which is better cte or subquery?

0 Answers  


How exception handling is done in advance pl/sql?

0 Answers  


Categories