User Tools

Site Tools


rowlimitingclause

This is an old revision of the document!


Row Limiting Clause

Display the highest 5 salaries

SELECT id, description, salary
  FROM employees
ORDER BY salary DESC
FETCH FIRST 5 ROWS ONLY;

Display the 6th to the 10th highest salaries

SELECT id, description, salary
  FROM employees
ORDER BY salary DESC
OFFSET 5 ROWS FETCH NEXT 5 ROWS ONLY;

Can also use NEXT 20 PERCENT ROWS in place of NEXT 5 ROWS.
Can place WITH TIES at the end. This can mean you will get more than the number of rows you specified.

rowlimitingclause.1437663024.txt.gz · Last modified: 2025/03/08 22:23 (external edit)