> For the complete documentation index, see [llms.txt](https://docs.digibee.com/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.digibee.com/documentation/resources/best-practices/pagination-example.md).

# Pagination example

Learn more about Pagination and see examples of how to implement paginated queries in the pipeline.

### **Input Json Example** <a href="#input-json-example" id="input-json-example"></a>

```json
{
    "page" : 1,
    "pageSize" : 50
}
```

### **Oracle** <a href="#h_2750facf09" id="h_2750facf09"></a>

```json
SELECT COL_A, COL_B
  FROM (SELECT COL_A,
               COL_B,
               row_number() over (order by COL_A) rn
          FROM XPTO.MY_TABLE )
WHERE rn BETWEEN {{ TOLONG(SUM(SUBTRACT(MULTIPLY(message.page, message.pageSize), message.pageSize), 1)) }}
AND {{ TOLONG(MULTIPLY(message.page, message.pageSize)) }}
```

### **SQL Server** <a href="#h_913678e9a1" id="h_913678e9a1"></a>

```sql
SELECT col_a, col_b FROM myTabel 
ORDER BY col_a  
OFFSET {{ TOLONG(SUM(SUBTRACT(MULTIPLY(message.page, message.pageSize), message.pageSize), 1)) }} ROWS 
FETCH NEXT {{ message.pageSize}} ROWS ONLY 
```

### Data Bricks (managed Apache Spark) <a href="#h_518bdfce52" id="h_518bdfce52"></a>

```apacheconf
WITH CTEResults AS 
( 
SELECT *, ROW_NUMBER() OVER (ORDER BY query.col_1) AS RowNum FROM( 
select distinct 
col_1, 
col_2, 
col_3 
from mytable 
where << YOUR FILTERS HERE>> 
order by col_1) query 
) 
SELECT * 
FROM CTEResults 
where RowNum > {{ TOLONG(SUBTRACT(MULTIPLY(message.page, message.pageSize), message.pageSize)) }} 
 and RowNum <= {{ TOLONG(MULTIPLY(message.page, message.pageSize)) }}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.digibee.com/documentation/resources/best-practices/pagination-example.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
