How to select Top 5 records from a table in MySQL?

Published on May 22, 2013 by abundantcode

Filed under MySQL

Last modified May 22, 2013

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 9207 times

Assume that you have a scenario where you need to retrieve the only the top 5 rows who has the maximum salary from the Employees table.

The column name is salary and the table name is Employees.

How to select Top 5 records from a table in MySQL?

To retrieve the Top 5 employees with maximum salary, order the records by descending order by salary and use the LIMIT keyword to retrieve the top 5 records as shown below.

SELECT salary FROM Employees ORDER BY salary DESC LIMIT 5

Leave a Comment


x

You might be Interested in these Posts

How to Display list of databases on a MySQL?

If you want to display the list of databases in a MySQL server, you can use the command 'show databa...

3 New C# 8 Features We Are Excited About

C# is rapidly approaching its third decade of life. Originally released in 2000, the language has gr...

Quick Tip —CSS Containment Module by @gilfink

One of the new hidden gems in the new CSS modules, which is supposed to drop in new browser versions...