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...

How do you retrieve the second highest salary from a table?

Answer Posted / glibwaresoftsolutions

Using a subquery:
SELECT MAX(salary)
FROM employees
WHERE salary < (SELECT MAX(salary) FROM employees);
Using ROW_NUMBER():
SELECT salary
FROM (
SELECT salary, ROW_NUMBER() OVER (ORDER BY salary DESC) AS row_num
FROM employees
) ranked
WHERE row_num = 2;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between clustered and non-clustered indexes?

1074


List and explain the different types of join clauses supported in ansi-standard sql?

1345


What does desc stand for?

1058


Is oracle sql free?

969


What are the steps for performance tuning.

1317


What are local and global Indexes and where they are useful.

1432


Is sqlite good enough for production?

982


What are different categories of sql commands?

1115


What is blind sql injection?

1046


Is there a pl/sql pragma similar to deterministic, but for the scope of one single sql select?

1004


Does sql*plus also have a pl/sql engine?

1068


What is bind reference and how can it be created?

1003


What are the types of variables use in pl sql?

1025


What are triggers in sql?

1005


What is secondary key?

920