PostgreSQL Fetch and Limit

Limit Clause

LIMIT "number of row(s)" [OFFSET "number of row(s)"];
LIMIT 3
is same as
LIMIT 3 OFFSET 0
SELECT column_list
FROM table
ORDER BY sort_method
LIMIT "number of row(s)" [OFFSET "number of row(s)"];

Fetch Clause

FETCH first/next "number of row(s)" only;
FETCH 5 ROWS ONLY
is same as
OFFSET 0
FETCH 5 ROWS ONLY
SELECT column_name
FROM table
ORDER BY sorting_method
OFFSET “number of row(s)"
FETCH first “number of row(s)” or next "number of row(s)” only;

Differences between them

--

--

--

Data Analyst | BI Analyst | Tableau Expert.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Five beautiful non-Apple dynamic Wallpapers for macOS

Introduce the Income Sharing Function

Get Flight Status Of American Airlines With An API

Okta OIDC integration with AWS Application Load Balancer (ALB)

What are SaaS, PaaS, and IaaS in Simple Words

Serverless DevOps Tools

How to use Huawei Ads with AdMob mediation (Flutter)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Yomisola Adegeye

Yomisola Adegeye

Data Analyst | BI Analyst | Tableau Expert.

More from Medium

How to set up CI/CD using docker and github actions

How to save JSON data in EXCEL file using Node.js Dynamically

Are you still using SQL ‘LIKE’?

Git, Github, what is it?