tags:

views:

45

answers:

2

I have 3 columns with id,usrnameand salary. I want to find maximum salary of 5 records. How will i write query in mysql ?

+6  A: 

In MySQL you can use ORDER BY to sort the rows in descending order and use LIMIT to return only the top 5 rows:

SELECT id, usrname, salary
FROM yourtable
ORDER BY salary DESC
LIMIT 5
Mark Byers
A: 

You have to use LIMIT, like so:

SELECT * FROM mytable ORDER BY salary DESC LIMIT 5
Weboide