Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Ordering
Limiting the output
8. TOP 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, TOP works with ORDER BY:

SELECT TOP 10
  *
FROM Order
ORDER BY TotalSum DESC;

The above code will return the 10 rows with the biggest TotalSum.

Exercise

This time, show the top five largest salaries from the Employee 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 TOP 5
  Salary,
  Position
FROM Employee
ORDER BY Salary DESC;