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 / hr@tgksolutions.com

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

Can we group by two columns in sql?

942


What is duration in sql profiler trace?

1018


What is sql prepared statement?

936


How do you sort in sql?

949


What is the purpose of a secondary key?

899


What are types of joins?

905


what is sp_pkeys? : Transact sql

1099


Why we use stored procedure instead of query?

949


Is sql the best database?

912


How to display the records between two range in Oracle SQL Plus?

1097


Can I join the same table twice?

992


What is row_number () in sql?

930


what does the t-sql command ident_current does? : Transact sql

925


What are the disadvantages of not performing database normalization?

1091


What is use of term?

1007