--- title: "Paginated SQL Query" slug: "paginated-sql-query" updated: 2021-08-05T19:27:53Z published: 2021-08-05T19:27:53Z canonical: "documentation.decisions.com/paginated-sql-query" --- > ## Documentation Index > Fetch the complete documentation index at: https://documentation.decisions.com/llms.txt > Use this file to discover all available pages before exploring further. # Paginated SQL Query Example Lab ArticleWhile Example Lab projects are resources for public use, articles and assets are not actively maintained. Screenshots and features are from the specified version below. These references may become dated as new versions are released. --- ## Overview | ## Example Lab Details | | --- | | **Version** | 6.16 | | **Root Folder** | Example Lab - Paginated SQL Query | | **Modules** | None | | **Dependencies** | None | This project demonstrates how a SQL query can be used to fetch paginated data through a Flow. Pagination describes data that has been split into groups called "pages" that are used to limit the data returned when retrieving it. --- ## Explanation This project includes a Query called "GetAccountsWithPagination" and a Flow called "Paginated Fetch." The query uses the filters "OFFSET x ROWS" and "FETCH NEXT y ROWS" to limit the data to a page where x indicates the page and y indicates the page size. The Flow has an input called PageNumber and Page Size. PageSize is multiplied by PageNumber to determine the offset. The calculated offset and page size are passed into the Query to get the specified page of data. Due to the way OFFSET works, PageNumber start at 0. PageSize must be greater than 0. Reference Articles[Adding Queries to a Database](https://documentation.decisions.com/v7/docs/add-query-external-database) ![](https://cdn.document360.io/6ef8bcc1-6489-4486-9ad1-83acff7e5df0/Images/Documentation/image-1628190200242.png) --- ## Project Download The examples attached were developed to be instructional and were not developed as officially supported components. For more information or to engage our service team to develop fully supported, production quality solutions, please contact services@decisions.com. Import the project below to a Decisions environment on version 6.16 or later using our [Importing/Exporting](https://documentation.decisions.com/docs/exporting-and-importing-overview) article. [ExampleLab.[PaginatedSQLQuery].zip](https://cdn.document360.io/6ef8bcc1-6489-4486-9ad1-83acff7e5df0/Images/Documentation/ExampleLab.%5BPaginatedSQLQuery%5D.zip) ---