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 ?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is oracle a relational database?

871


Explain the use of record option in exp command.

949


Can you assign multiple query result rows to a variable?

933


What are the varoius components of physical database structure of oracle database?

946


What is a database table in oracle?

954


What is the parameter mode that can be passed to a procedure?

981


Select all the employees who were hired in last 2 years and who works in dept where max managers are working.

2903


What do you understand by a database object?

990


How to establish administrator authentication to the server?

984


How to create a stored program unit?

1121


Can u please explain me the Discussion on Except ,using cast like type cast. Question in the context of difference between two tables

1999


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

1047


How to build data dictionary view an new database?

960


How to retrieve data from an cursor to a record?

1019


What is user managed backup in Oracle?

1078