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

What is backup in Oracle?

0 Answers   MCN Solutions,


difference between procedures and function?

7 Answers   IBM,


how to delete all duplicate records from a table using subquery?

7 Answers   ABC, Cap Gemini,


Database is hung. Old and new user connections alike hang on impact. What do you do? Your SYS SQLPLUS session IS able to connect.

0 Answers  


Can select statements be used on views in oracle?

0 Answers  


What is the Tune Query

0 Answers  


Hi All, Recently I attended a interview for a developer position in an educational university. They asked me the a question, I answered somehow but I was not not satisfied myself. Can anybody reply for it? The question is: A business user comes to you directly with an urgent request:: there is a problem with some students not being able to re-enrol. It appears that ?something has gone wrong with the end-dating of some previous courses they had enrolled in, and this is preventing them from completing their on-line re-enrolments?. Fortunately the user has done some analysis on the situation, and has developed some code to change the end dates. They tell you that they have tested this code in the ?dev? environment, and it works fine. They are asking you to please get this implemented in production as soon as possible. What steps would you take in response to their request ? Thanks

2 Answers  


What is materialized view in Oracle?

0 Answers   MCN Solutions,


i have procedure p1.and also i declare the same procedure in a package. whice one is efficient package procedure or procedure?

2 Answers   Microsoft,


What is the maximum limit on the number of columns in a table?

0 Answers  


Hi Can any one tell me what are the API's used in requisition import.

0 Answers  


How to login to the server without an instance?

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)