Skip Rows with OFFSET
Return employees 4 through 6 (skip the first 3).
- CTEs
- Sorting
- Top-N
Interview brief
Understand the request
HR operations analyst The second page of the employee directory starts after the first 3 records.
Skip the first 5 employees by employee_id and return the next 5. Show first_name, last_name, salary, employee_id.
Return
- Return all employee columns.
Constraints
- Use OFFSET 3 to skip the first page.
Data you will use
Review the relevant tables before deciding how to join, filter, or aggregate them.
employees
first_nameTEXTlast_nameTEXTsalaryDECIMALemployee_idINTEGER
Hints, when you need them
Open one clue at a time so you still do the reasoning.
Hint 1
OFFSET M skips M rows from the start of the (ordered) result; LIMIT N then keeps the next N.
Hint 2
Without ORDER BY, 'skip the first 5' has no defined meaning — the engine may give different rows each run.
Hint 3
ORDER BY employee_id LIMIT 5 OFFSET 5
Verified SQL answer
Attempt the problem first, then compare structure and reasoning—not just syntax.
Reveal solution and explanation
SELECT first_name, last_name, salary, employee_id FROM employees ORDER BY employee_id LIMIT 5 OFFSET 5;Why this works
OFFSET is the foundation of pagination. The cost: the engine must produce and discard the first M rows before returning anything. For small offsets this is fine; for very large offsets it gets expensive (covered in Q14 and Q22).
Expected result
Use this output to verify values, aliases, ordering, and row count.
| first_name | last_name | salary | employee_id |
|---|---|---|---|
| Lisa | Davis | 58000 | 6 |
| Tom | Wilson | 62000 | 7 |
| Amy | Taylor | 78000 | 8 |
| Chris | Anderson | 68000 | 9 |
| Emma | Thomas | 52000 | 10 |
Learn the concepts behind this answer
Strengthen your understanding with these targeted learning topics: