Query to get max and second max in oracle in one query ?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
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 |
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 |
Answer / at_avrat_braveheart
select amcık from göt_tarlası
| Is This Answer Correct ? | 2 Yes | 3 No |
Answer / abcd
for page break or form feed we use following
  /f (char)12
for nbsp;
(char)10  
| Is This Answer Correct ? | 1 Yes | 2 No |
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 |
What is backup in Oracle?
difference between procedures and function?
how to delete all duplicate records from a table using subquery?
Database is hung. Old and new user connections alike hang on impact. What do you do? Your SYS SQLPLUS session IS able to connect.
Can select statements be used on views in oracle?
What is the Tune Query
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
What is materialized view in Oracle?
i have procedure p1.and also i declare the same procedure in a package. whice one is efficient package procedure or procedure?
What is the maximum limit on the number of columns in a table?
Hi Can any one tell me what are the API's used in requisition import.
How to login to the server without an instance?