---
schema_version: "1"
id: 75b9076f737f178b48161f970c3acc55fe436a1a319b98fa14f81045ab89a027
title: LIMIT
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-soql-sosl/guides/soql-sosl/sforce-api-calls-soql-select-limit.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-soql-sosl/guide/sforce-api-calls-soql-select-limit.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: d5f3df788a100cc0d96681c696b98db6a9a69ff8fc34728dc5e97efa17d345e9
products:
  - SOQL and SOSL Reference
  - Platform Developer Content
---

# LIMIT

`LIMIT` is an optional clause that can be added to a `SELECT` statement of a SOQL query to specify the maximum number of rows to return.

The syntax for `LIMIT` is:

```soql
SELECT fieldList
FROM objectType
[WHERE conditionExpression]
  [LIMIT numberOfRows]
```

For example:

<!-- otherprops: soql -->

```codesegment
SELECT Name
FROM Account
WHERE Industry = 'Media' LIMIT 125
```

This query returns the first 125 Account records whose Industry is `Media`.

You can use `LIMIT` with `count()` as the fieldList to count up to the maximum specified.

You can't use a `LIMIT` clause in a query that uses an aggregate function, but does not use a `GROUP BY` clause. For example, the following query is invalid:

<!-- otherprops: set_clipboard -->

```soql
SELECT MAX(CreatedDate)
FROM Account LIMIT 1
```
