← All Exercises
SQL ORDER BY and LIMIT
basicsql
Background
ORDER BY sorts results, and LIMIT/OFFSET restricts the number of rows for pagination.
Problem
Write a SQL query to get the top 5 highest-paid employees with pagination support using LIMIT and OFFSET.
Input
An employees table with id, name, salary columns and a page number.
Output
5 employees for the requested page, ordered by salary descending.
Sample tests
Sample 1
Input: page 1 of 10 employees, 5 per page
Expected: top 5 highest-paid employees
Your solution
Learning objective
Learn ORDER BY, LIMIT, OFFSET for pagination, and deterministic result ordering.