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 get second highest salary in SQL(as/4000

Answers were Sorted based on User's Feedback



how to get second highest salary in SQL(as/4000..

Answer / santosh kumar

select employee_id,last_name,salary
from
(select rownum r,employee_id,last_name,salary
from (select employee_id,last_name,salary from employees
order by salary desc)) a
where a.r=&nth_salary;

---u can find nth highest salary----
for more detail u can contact me at
rajgupta7666@gmail.com....

Is This Answer Correct ?    2 Yes 0 No

how to get second highest salary in SQL(as/4000..

Answer / selvaspak

select sal from (select sal,rank() over(order by sal desc)
as rank from emp) where rank = &no

Actually for this Question there are having lot of method
to get the result, but the interviewer is asking this for
to check whether the interview person know the RANK()
function or not. So the above query is correct

Is This Answer Correct ?    1 Yes 0 No

how to get second highest salary in SQL(as/4000..

Answer / mohamed shahid

select * from (select sal,rownum rn from(select sal from emp order by sal desc)) where rn=2;

Is This Answer Correct ?    1 Yes 0 No

how to get second highest salary in SQL(as/4000..

Answer / dharmendra

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

Is This Answer Correct ?    2 Yes 2 No

how to get second highest salary in SQL(as/4000..

Answer / tauseef

select last_name,salary from(
select last_name,salary ,rownum rk from(
select distinct salary,last_name from employees order by
salary desc nulls last))
where rk=9


By this way u can find 2nd,3rd n nth highest salary wit the
name

Is This Answer Correct ?    0 Yes 0 No

how to get second highest salary in SQL(as/4000..

Answer / amedela chandra sekhar

SQL> select * from emp where sal=(select max(sal) from emp
2 where sal<(select max(sal)from emp));

EMPNO ENAME JOB MGR HIREDATE
SAL COMM
---------- ---------- --------- ---------- ---------
---------- ----------
DEPTNO
----------
7788 SCOTT ANALYST 7566 19-APR-87 3000
20

7902 FORD ANALYST 7566 03-DEC-81 3000
20

Is This Answer Correct ?    0 Yes 0 No

how to get second highest salary in SQL(as/4000..

Answer / sachin

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

Is This Answer Correct ?    0 Yes 0 No

how to get second highest salary in SQL(as/4000..

Answer / chandu

select max(sal) from new where sal not in(select max(sal)
from new);

Is This Answer Correct ?    0 Yes 0 No

how to get second highest salary in SQL(as/4000..

Answer / s. syam sundar

1.SELECT LEVEL,MAX(SAL) FROM EMP WHERE LEVEL = 2 CONNECT BY
PRIOR SAL >SAL GROUP BY LEVEL
2.SELECT SAL FROM (SELECT SAL FROM EMP ORDER BY SAL DESC)
WHERE ROWNUM <3
MINUS
SELECT SAL FROM (SELECT SAL FROM EMP ORDER BY SAL DESC)
WHERE ROWNUM = 1
3.SELECT MAX(SAL) FROM EMP WHERE SAL <> (SELECT MAX(SAL)
FROM EMP)

regards
syam sundaar

Is This Answer Correct ?    4 Yes 5 No

how to get second highest salary in SQL(as/4000..

Answer / praveen agrawal

select sal from employee order by sal desc limit 1,1;

its 100% true i have checked it out.

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More SQL PLSQL Interview Questions

What are the advantages of stored procedure?

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,


What is the difference between microsoft access and sql?

0 Answers  


Is null operator in sql?

0 Answers  


..........refers to the disk mirroring

2 Answers   iFlex,


What operators deal with null?

0 Answers  


Is sql harder than python?

0 Answers  


is mysql query is case sensitive? : Sql dba

0 Answers  


how to insert the data through views? The view is depending upon more than two tables? how to update materalized views?

3 Answers   3i Infotech,


Enlist some predefined exceptions?

0 Answers  


Why you are not able to create a table using select command,if it is having a LONG column? for eg:create table test as select * from test1 here test1 containg a column having LONG datatype...

1 Answers  


How to return multiple rows from the stored procedure?

0 Answers  


Categories