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 sal of emp table

Answers were Sorted based on User's Feedback



how to get second highest sal of emp table..

Answer / yadunandan

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

Is This Answer Correct ?    5 Yes 2 No

how to get second highest sal of emp table..

Answer / anilchandu

Select * from emp x where 2=(select count(distinct sal)
from emp y where x.sal<=y.sal)


where x,y are alias names.

If you want 3rd heighest salary then just replace 2 by 3

Is This Answer Correct ?    2 Yes 0 No

how to get second highest sal of emp table..

Answer / manjeet

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

Is This Answer Correct ?    1 Yes 0 No

how to get second highest sal of emp table..

Answer / prabhudatta barick

--IN ORDER TO FIND THE NTH HIGHEST SALARY,
--WE JUST FIND THE SALARY THAT HAS EXACTLY N-1 SALARIES
GREATER THAN ITSELF---

--This is correlated subquery--
select empno,
ename,
sal
from scott.emp e
where &n-1=(select count(distinct b.sal) from scott.emp b
where b.sal>e.sal);

To get second highest salary put n value 2.

Is This Answer Correct ?    1 Yes 0 No

how to get second highest sal of emp table..

Answer / rakhi

SELECT *
FROM (
SELECT employee_id, last_name, salary,
RANK() OVER (ORDER BY salary DESC) EMPRANK
FROM employees)
WHERE emprank = 2;

Is This Answer Correct ?    2 Yes 2 No

how to get second highest sal of emp table..

Answer / amit bhagat

select min(a.sal) from (select disctinct d.sal from emp d
order by sal desc) a where rownum<=2

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Oracle General Interview Questions

what is the difference between authorization and authentication?

4 Answers   MAHINDRA, PUCIT,


How to define a procedure inside another procedure?

0 Answers  


What is the difference between post-database commit and post-form commit?

0 Answers  


What is the exact use of Collections?

0 Answers  


ex. one table is having 1 column with 10 records , then how to display all the values in row wise ?

4 Answers  


Explain what are the uses of rollback segment?

0 Answers  


Assuming that you are an End User How to find that in the payment Batch some of the Invoice was  Missing To pay How to find That??

0 Answers  


Describe Referential Integrity ?

1 Answers  


Difference between cartesian join and cross join?

0 Answers  


Q1:code to connect to sql server(database) through jdbc application. Q2:code to connect to Mysql(database) through jdbc application. Q3:code to connect to oracle(database) through jdbc application.

1 Answers  


What privilege is needed for a user to create tables in oracle?

0 Answers  


How to add a new column to an existing table with a default value?

0 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1809)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)