---
title: LIMIT
description: Cap the number of rows a ShopifyQL query returns.
api_version: 2026-07
source_url:
  html: 'https://shopify.dev/docs/api/shopifyql/latest/syntax/limit'
  md: 'https://shopify.dev/docs/api/shopifyql/latest/syntax/limit.md'
api_name: shopifyql
---

# LIMIT

Use `LIMIT` to cap the number of rows a query returns, and add `OFFSET` to skip rows before the limit applies. Because result order isn't guaranteed without sorting, pair `LIMIT` with [`ORDER BY`](https://shopify.dev/docs/api/shopifyql/latest/syntax/order-by) to return a stable set of rows.

## Syntax

```shopifyql
LIMIT count [OFFSET count]
```

***

## Row limit and offset

Set the maximum number of rows the query returns. Add `OFFSET` to skip a number of rows first, which pages through results in fixed-size pages. Pair `LIMIT` with [`ORDER BY`](https://shopify.dev/docs/api/shopifyql/latest/syntax/order-by) so the rows you keep are deterministic.

* **LIMIT**

  **LIMIT \<count>**

  Returns at most the specified number of rows.

* **OFFSET**

  **LIMIT \<count> OFFSET \<count>**

  Skips rows before returning the limited result set.

Examples

### Examples

* ####

  ##### Description

  Rank \[\`total\_sales\`]\(/docs/api/shopifyql/latest/schemas/sales\_revenue/sales#salesmetric-propertydetail-totalsales) by product over the last 30 days, keeping only the 10 highest. This example uses \`LIMIT 10\` to cap the result at ten rows after \[\`ORDER BY\`]\(/docs/api/shopifyql/latest/syntax/order-by) sorts them.

  ##### ShopifyQL

  ```shopifyql
  FROM sales
    SHOW total_sales
    GROUP BY product_title
    SINCE -30d UNTIL today
    ORDER BY total_sales DESC
    LIMIT 10
  ```

* ####

  ##### Description

  List \[\`sessions\`]\(/docs/api/shopifyql/latest/schemas/sessions\_and\_behavior/sessions#sessionsmetric-propertydetail-sessions) by landing page for last month, skipping the top 10 and returning the next 10. This example uses \`LIMIT 10 OFFSET 10\` to page through the ranked rows in blocks of ten.

  ##### ShopifyQL

  ```shopifyql
  FROM sessions
    SHOW sessions
    GROUP BY landing_page_path
    DURING last_month
    ORDER BY sessions DESC
    LIMIT 10 OFFSET 10
  ```

***
