**Source URL:** https://limited.veevavault.dev/medical/vql/clauses/maxrows

# MAXROWS

In v20.3+, use the `MAXROWS` clause to retrieve a maximum of N results, applied after any filters.

## Syntax

```sql
SELECT {fields}
FROM {query target}
MAXROWS {number}
```

## Query Examples

The following are examples of queries using `MAXROWS`.

### Query: Retrieve a Maximum of N Documents

The following query returns a maximum of 500 documents:

```sql
SELECT id
FROM documents
MAXROWS 500
```

### Query: Use MAXROWS with PAGESIZE

When used with the [`PAGESIZE` clause](/medical/vql/clauses/pagesize), the `MAXROWS` clause must come first. The following query returns a maximum total of three (3) documents with one (1) result per page:

```sql
SELECT username__sys
FROM user__sys
MAXROWS 3
PAGESIZE 1
```

---

**Previous:** [ORDER BY](/medical/vql/clauses/order-by)  
**Next:** [SKIP](/medical/vql/clauses/skip)