IBM Support

How to use SQL pagination using LIMIT and OFFSET

Troubleshooting


Problem

How to extract just a portion of a larger result set from a SQL SELECT.
 

Resolving The Problem

LIMIT n is an alternative syntax to the FETCH FIRST n ROWS ONLY.

The OFFSET clause specifies the number of rows of the result table to skip before any rows are retrieved,
and must be used with the LIMIT clause.
The OFFSET clause instructs the server where to start returning rows within the query result.
For example, if a query returns 100 rows, specifying OFFSET 10 instructs the server to skip
the first 10 rows of the query results:
SELECT *
FROM PART_DI21PART_STAININFO
ORDER BY record_id
LIMIT 100 OFFSET 10
OFFSET can also be abbreviated, e.g.
LIMIT 100,10

Document Location

Worldwide

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SS4NKG","label":"IBM Data Virtualization Manager for z\/OS"},"ARM Category":[{"code":"","label":""}],"Platform":[{"code":"PF035","label":"z\/OS"}],"Version":"All Versions","Line of Business":{"code":"LOB10","label":"Data and AI"}},{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSKRKK","label":"IBM Db2 Analytics Accelerator Loader for z\/OS"},"ARM Category":[{"code":"","label":""}],"Platform":[{"code":"PF035","label":"z\/OS"}],"Version":"All Versions","Line of Business":{"code":"LOB10","label":"Data and AI"}},{"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SS3H8V","label":"IBM Open Data Analytics for z\/OS"},"ARM Category":[{"code":"a8m0z000000cxHeAAI","label":"IBM z\/OS Mainframe Data Service for Apache Spark"}],"Platform":[{"code":"PF035","label":"z\/OS"}],"Version":"1.2.0","Line of Business":{"code":"LOB35","label":"Mainframe SW"}},{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SS6QWT","label":"IBM QMF Analytics for Multiplatforms"},"ARM Category":[{"code":"a8m0z000000cxH0AAI","label":"QMF Data Service"}],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Version(s)","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
03 February 2021

UID

ibm16409566