# Pagination example

### **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: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
