---
schema_version: "1"
id: 4cc5fe182f3918e95e2b8fdf267e354a8e0aaae409f156277b30516d67e713c8
title: Limit and Order Your Query Results
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/data-cloud-query-guide/guides/get-started-dc-sql/limit-order-query-results.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-query-guide/guide/limit-order-query-results.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 99c7ce6695f3221b7ea780a941906a68f88899c91fb4920c53b31dbc479b2720
products:
  - Data 360 Query Guide
  - Data 360 Developer Documentation
---
# Limit and Order Your Query Results

A query result set can be large if your Data 360 org contains a lot of data. To limit the query result, use
the `LIMIT` clause. The `LIMIT` clause returns the first `n` rows that the data store returns, where `n` is the number of rows specified.

This query returns 20 unified individuals only.

```
SELECT "ssot__Id__c",
       "ssot__FirstName__c",
       "ssot__LastName__c",
       "ssot__BirthDate__c"
FROM "UnifiedIndividual__dlm"
LIMIT 20

```

The `LIMIT` clause doesn’t guarantee the order of the rows returned. You can get different results if you run the query at different times. A more reproducible query combines the `LIMIT` clause with the `ORDER BY` clause so that the results returned are in the same order in each query execution.

This query returns the top 20 oldest unified individuals based on the birth date.

```
SELECT "ssot__FirstName__c",
       "ssot__LastName__c",
       "ssot__BirthDate__c"
FROM "UnifiedIndividual__dlm"
ORDER BY "ssot__BirthDate__c"
LIMIT 20

```

This query output shows the first few rows returned for unified individuals from the result set of 20 rows. The rows are ordered by birth date.

| `ssot__FirstName__c` | `ssot__LastName__c` | `ssot__BirthDate__c`       |
| -------------------- | ------------------- | -------------------------- |
| `Avi`                | `Green`             | `1937-03-12T00:00:00.000Z` |
| `Babara`             | `Levy`              | `1940-07-20T00:00:00.000Z` |
| `Edna`               | `Frank`             | `1945-10-23T00:00:00.000Z` |
| `Stella`             | `Pavlova`           | `1946-12-04T00:00:00.000Z` |
| `...`                | `...`               | `...`                      |

The `ORDER BY` clause orders in ascending order by default. To order the result in descending order, use the `DESC` keyword. This `ORDER BY` clause in the query returns the top 20 youngest individuals.

```
ORDER BY "ssot__BirthDate__c" DESC
```

To retrieve a subset of the returned result set, use `OFFSET` to return the row after the specified row number. Use `OFFSET` with `ORDER BY` to get the same result set in subsequent queries.

Suppose you already displayed the first two rows of the oldest individuals. You want the next two rows. You can use this query with an offset of 2 and a limit of 2.

```
SELECT  "ssot__FirstName__c",
        "ssot__LastName__c",
        "ssot__BirthDate__c"
FROM "UnifiedIndividual__dlm"
ORDER BY "ssot__BirthDate__c"
LIMIT 2
OFFSET 2

```

This query returns rows 3 and 4 from the previous output. The rows are ordered by birth date.

| `ssot__FirstName__c` | `ssot__LastName__c` | `ssot__BirthDate__c`       |
| -------------------- | ------------------- | -------------------------- |
| `Edna`               | `Frank`             | `1945-10-23T00:00:00.000Z` |
| `Stella`             | `Pavlova`           | `1946-12-04T00:00:00.000Z` |
