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

Answer Posted / rohit

The below query will provide the max and second max in
oracle in one query

select * from emp e
where 0 = (select count(sal) from emp
where e.sal < sal)
or 1 = (select count(sal) from emp
where e.sal < sal);

Is This Answer Correct ?    17 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

> CREATE OR REPLACE FUNCTION FACTORIAL_1(factstr varchar2 ) 2 RETURN NUMBER AS 3 new_str VARCHAR2(4000) := factstr||'*' ; 4 fact number := 1 ; 5 BEGIN 6 7 WHILE new_str IS NOT NULL 8 LOOP 9 fact := fact * TO_NUMBER(SUBSTR(new_str,1,INSTR(new_str,'*')-1)); 10 new_str := substr( new_str,INSTR(new_str,'*')+1); 11 END LOOP; 12 13 RETURN fact; 14 15 END; explanation Above program?

1569


What are the limitations oracle database 10g xe?

572


What is a cognitive schema?

529


Explain drop constraint oracle?

593


How to enter a new row into a table interactively?

550






HI Friends Myself Manoj,i am from bengaluru.i have 1 yr of exp in PLSQL but not upto the mark..now attending interviews but m not able to clear even 1 round..i have attended 3 interviews till today.purpose of writing this query is,i want to know the intreview topics that interviewer going to ask frequently,mainly SCENARIO based questions.IF anybody have any PLSQL projects please give it to me,it will helps me alot.Thanks for your patience.

997


How do I call oracle stored procedures that take no parameters?

567


What is query image?

586


What is an external table?

588


How to delete multiple rows from a table in oracle?

563


What is the use of file param in imp command?

646


How to manage transaction isolation level?

564


Explain oracle’s server parameter file.

566


How do I recompile a procedure in oracle?

527


What are the attributes that are found in a cursor?

650