0

Possible Duplicate:
How to select top N from a table

How can a write a query for selecting the top 5 salaries from table ?

Community
  • 1
  • 1
shailesh
  • 59
  • 2
  • 2
  • 7
  • 2
    Ok, I'll take 2! This isn't a real question, and you haven't given any context (e.g. table schema). Voted to close. – Mark Peters Mar 14 '11 at 14:29
  • 1
    Please read the FAQ and try to ask a question that can be answered: http://stackoverflow.com/faq – razlebe Mar 14 '11 at 14:30
  • 1
    Give him a chance to clarify before you close his question, there's obviously a real question here. @shailesh please specify what database you're using and provide some context to your question (table structure) – theChrisKent Mar 14 '11 at 14:33
  • What would your answer have to be if there were 10 people with the same salary and that is the second highest? – Rajesh Chamarthi Mar 14 '11 at 14:37

3 Answers3

3
SELECT TOP 5 Salary
   FROM SalariesTable
   ORDER BY Salary DESC
theChrisKent
  • 15,029
  • 3
  • 61
  • 62
2
SELECT TOP 5 Salary
FROM Salaries
ORDER BY Salary DESC
froadie
  • 79,995
  • 75
  • 166
  • 235
2

To get the TOP 5 highest Salaries:

SELECT DISTINCT TOP 5 MAX(Salary)
  FROM Salaries
 GROUP
    BY Salary
 ORDER 
    BY Salary DESC;
Community
  • 1
  • 1
Neil Knight
  • 47,437
  • 25
  • 129
  • 188