Best April deals - hours only!Up to 80% off on all courses and bundles.-Close
Ordering
Limiting the output
8. LIMIT ordered values
Eliminating duplicate results
Aggregation
Grouping
HAVING: filtering and ordering groups
Let's practice

Instruction

Great! Sometimes you may want to look at sorted data. Thankfully, LIMIT works with ORDER BY:

SELECT *
FROM orders
ORDER BY total_sum DESC
LIMIT 10;

The above code will return the 10 rows with the highest total_sum.

Exercise

This time, show the top ten highest salaries from the employees table. Select the position column as well. Modify the answer from the previous exercise.

You can try running the template before solving the exercise in order to see the difference for yourself.

Stuck? Here's a hint!

Type:

SELECT
  salary,
  position
FROM employees
ORDER BY salary DESC
LIMIT 10;