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...


Query to get max and second max in oracle in one query ?

Answers were Sorted based on User's Feedback



Query to get max and second max in oracle in one query ?..

Answer / satish

SELECT SAL FROM (SELECT SAL,DENSE_RANK() OVER(ORDER BY SAL DESC) RANK FROM EMP) WHERE RANK=2;

Is This Answer Correct ?    0 Yes 0 No

Query to get max and second max in oracle in one query ?..

Answer / satish

SELECT SAL SECOND_MAX_SAL FROM (SELECT SAL,DENSE_RANK() OVER(ORDER BY SAL DESC) RANK FROM EMP) WHERE RANK=2;

Is This Answer Correct ?    0 Yes 0 No

Query to get max and second max in oracle in one query ?..

Answer / sunil

select sal from (select dense_rank() over(order by sal) rank
from emp) where rank in(1,2);

In above query you will get both highest and second highest
salary details even there are more people who are getting
highest and second highest salary.

Is This Answer Correct ?    0 Yes 0 No

Query to get max and second max in oracle in one query ?..

Answer / purna chowdary

Select Sal From Emp A
WHERE 1=(Select Count(Sal) From Emp B
WHERE B.Sal>A.sal)
GROUP By Sal Desc

Is This Answer Correct ?    0 Yes 0 No

Query to get max and second max in oracle in one query ?..

Answer / shareef

select ename,empno,sal,r from(select ename,empno,sal,dense_rank() over(order by sal desc) r from emp) where r=3; ----by using dense_rank()

Is This Answer Correct ?    0 Yes 0 No

Query to get max and second max in oracle in one query ?..

Answer / ajit

select max(sal),1 no
from emp
union
select sal,rn from (select sal,rownum rn from emp)
where rn = 2
order by 1 desc;

Is This Answer Correct ?    0 Yes 0 No

Query to get max and second max in oracle in one query ?..

Answer / asdasd

SELECT min(gross) FROM(SELECT distinct(gross) FROM
srbs_staff_pay_dtls ORDER
BY gross DESC) WHERE ROWNUM<=4;

Is This Answer Correct ?    2 Yes 3 No

Query to get max and second max in oracle in one query ?..

Answer / at_avrat_braveheart

select amc&#305;k from göt_tarlas&#305;

Is This Answer Correct ?    2 Yes 3 No

Query to get max and second max in oracle in one query ?..

Answer / abcd

for page break or form feed we use following
&#12; &#x0C; /f (char)12
for nbsp;
(char)10 &#160;

Is This Answer Correct ?    1 Yes 2 No

Query to get max and second max in oracle in one query ?..

Answer / sarmistha mohanty

select * from (
select SAL,
row_number() over (partition by 1 order by SAL DESC)
as rank
from <table name> ) where rank in (1,2)

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More Oracle General Interview Questions

How index is implemented in oracle database?

0 Answers  


what are actual and formal parameters?

0 Answers  


What are the types of synonyms?

1 Answers  


How to use subqueries in the from clause in oracle?

0 Answers  


What happens if you use a wrong connect identifier?

0 Answers  


How to define an anonymous procedure without variables?

0 Answers  


What is Trace File ?

4 Answers   Thermotech,


find out the second highest salary?

55 Answers   Cognizant, Nucsoft, Oracle, TCS, Wondersoft,


What are the common oracle dba tasks?

0 Answers  


how to produce numbers from 1 to 10 using dual table

4 Answers   Genpact,


please explain.. DB architecture ...

0 Answers  


I just want to maintain data like an employee can belongs to 3 or more departments . We can resolve this by using composite key but it avoids normalization rules. So Can anyone tell me how can I maintain data.

0 Answers   IBM,


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)