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 / shashank yadav

Select Max(sal) from emp
where sal < any (select sal from emp);

Is This Answer Correct ?    3 Yes 1 No

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

Answer / assdads

five times tapping shift key helps to go woth out a mouse
by using number key.you can copy data in form by pressing
shift+insert.

Is This Answer Correct ?    2 Yes 1 No

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

Answer / raghav

SELECT MAX(SAL)
FROM EMPLOY
WHERE SAL < ( SELECT MAX(SAL) FROM EMPLOY )

Is This Answer Correct ?    5 Yes 4 No

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

Answer / vaibhav

SELECT Sal
FROM (Select Sal from Emp_Salary order by Sal desc)
WHERE rownum < =2;


Above query will fetch two rows. First row is the max salary
and second row second max.

IF we only need to find second max, then

SELECT Min(Sal)
FROM (Select Sal from Emp_Salary order by Sal desc)
WHERE rownum < =2;

Is This Answer Correct ?    4 Yes 3 No

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

Answer / amit golia

SELECT min(sal) FROM(SELECT DISTINCT(sal) FROM emp ORDER
BY sal DESC) WHERE ROWNUM<=2;

Is This Answer Correct ?    2 Yes 1 No

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

Answer / kevin sharpless

-- This query wiil return any number of the n items by
using the max/decode statements

select max(decode(rnum,1,salary,null)) max1
,max(decode(rnum,2,salary,null)) max2
from (
select 1 grp_col
,salary
,row_number() over (order by salary asc) rnum
from (
select distinct salary
from emp
)
)
group by grp_col

Is This Answer Correct ?    1 Yes 0 No

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

Answer / haddy

select ename,salary from (select distinct(salary) from
employee order by salary desc) where rownum<=2

Is This Answer Correct ?    1 Yes 0 No

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

Answer / roopa

SELECT MAX(E1.sal), MAX(E2.sal)
FROM emp E1, (SELECT sal FROM emp
WHERE sal NOT IN ( SELECT MAX(sal) FROM emp)) E2

Is This Answer Correct ?    7 Yes 7 No

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

Answer / zyxw

for removing lines between word document and to get in a
paragarph manner
first do ctrl+h and then put ^p and leave replace with
empty.and go for
replace or replace all depending on the situation.

Is This Answer Correct ?    2 Yes 2 No

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

Answer / deepa

select salary from (select salary from table_name order by salary desc) where rownum<3;

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More Oracle General Interview Questions

How to count duplicated values in a column in oracle?

0 Answers  


How to return top 5 rows in oracle?

0 Answers  


Display the number value in Words?

1 Answers  


Why do I get unexpected characters from 8-bit character sets in weblogic jdriver for oracle?

0 Answers  


How to retrieve data from an cursor to a record?

0 Answers  


What is the max number of columns in an oracle table?

0 Answers  


6. Display the client name and order date for all orders using the traditional method.

0 Answers   Wipro,


Indexes in oracle ?

3 Answers   Keane India Ltd, L&T,


What is the relationship among database, tablespace and data file?

0 Answers  


What is Database Trigger ?

1 Answers  


How to write text literals in oracle?

0 Answers  


what are different types of deletes?

1 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)