Postgresql は返される結果の数を制限します
TOP-N クエリ
select first_name,last_name,salary
from employees
order by salary
fetch first 10 rows only;
select first_name,last_name,salary
from employees
order by salary
limit 10;
select first_name,last_name,salary
from employees
order by salary
fetch first 10 rows with ties;
ページングクエリ
SELECT first_name, last_name, salary
FROM employees
ORDER BY salary DESC
OFFSET 10 ROWS
FETCH FIRST 10 ROWS ONLY;
SELECT first_name, last_name, salary
FROM employees
ORDER BY salary DESC
LIMIT 10 OFFSET 20;
要約する