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:

SELECT fieldList
FROM objectType
[WHERE conditionExpression] 
  [LIMIT numberOfRows]

For example:

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:

SELECT MAX(CreatedDate)
FROM Account LIMIT 1