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 |
How do we create privileges in oracle?
What would you use to improve performance on an insert statement that places millions of rows into that table?
How to do a full database export?
What is the difference between Outer join and Full outer join?
What are temporal data types in oracle?
what is reindexing?
interview questions with answer for cts
What is blob datatype?
How to call a stored function in oracle?
Explain the use of indexes option in imp command.
I have a table like this Table Name:Products Productid Price 1 10 1 10 2 20 3 30 3 30 But i want to output like this. productid price 2 20. please replay me.
What are the general rules on data consistency?