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
2010-06-24 22:34:15
A:
You have to use LIMIT, like so:
SELECT * FROM mytable ORDER BY salary DESC LIMIT 5
Weboide
2010-06-24 22:36:28