Search⌘ K
AI Features

Question: Sorting the Records

Explore how to write SQL queries that sort records by salary and retrieve the top three highest-paid employees from the Employees table. This lesson helps you practice ORDER BY statements and understand sorting techniques in SQL.

Question

Given the following Employees table structure:

Employees

EmpID

EmpName

Salary

1

Susan Lee

50000.00

2

Alexa Smith

60000.00

3

Sana Amberson

45000.00

4

Sarah Ronald

47000.00

Additional information

You are provided with a table named Employees that contains the following columns:

  • EmpID: Unique identifier for each employee

  • EmpName: The name of the employee

  • Salary: The salary of an employee

Let’s say you’re part of a team managing a database for your company. One of the tables, called Employees, holds important details like names and salaries. Here’s a task for you: Can you write an SQL ORDER BY query to find the top three highest-paid employees and sort them by their salary?

So, put on your database explorer hat and see if you can find the answer!

Expected output

The expected output is shown below:

EmpName

Salary

Alexa Smith

60000.00

Susan Lee

50000.00

Sarah Ronald

47000.00

Try it yourself

You can try to write a query in the following playground:

MySQL
/* Write your query below */

Hints

Below are some hints to help you understand these concepts better: