> ## Documentation Index
> Fetch the complete documentation index at: https://docs.filefetch.app/llms.txt
> Use this file to discover all available pages before exploring further.

# SOQL Query Examples

> Common SOQL patterns for querying Salesforce files

## Basic File Queries

### All Recent Files (Latest Versions Only)

```sql theme={null}
SELECT Id, Title, ContentDocumentId, FileExtension, ContentSize, CreatedDate
FROM ContentVersion
WHERE IsLatest = true
ORDER BY CreatedDate DESC
LIMIT 100
```

### Files from Last 30 Days

```sql theme={null}
SELECT Id, Title, ContentDocumentId, CreatedDate
FROM ContentVersion
WHERE IsLatest = true
  AND CreatedDate = LAST_N_DAYS:30
ORDER BY CreatedDate DESC
```

### PDFs Only

```sql theme={null}
SELECT Id, Title, ContentDocumentId, FileExtension
FROM ContentVersion
WHERE IsLatest = true
  AND FileExtension = 'pdf'
LIMIT 500
```

### Large Files (>10MB)

```sql theme={null}
SELECT Id, Title, ContentDocumentId, ContentSize
FROM ContentVersion
WHERE IsLatest = true
  AND ContentSize > 10485760
ORDER BY ContentSize DESC
LIMIT 100
```

## Legacy Attachments

### Recent Attachments

```sql theme={null}
SELECT Id, Name, BodyLength, ParentId, CreatedDate
FROM Attachment
WHERE CreatedDate = LAST_N_DAYS:90
ORDER BY CreatedDate DESC
LIMIT 200
```

### PDF Attachments

```sql theme={null}
SELECT Id, Name, BodyLength, CreatedDate
FROM Attachment
WHERE Name LIKE '%.pdf'
ORDER BY CreatedDate DESC
LIMIT 500
```

## More Examples

<CardGroup cols={2}>
  <Card title="Power Mode Guide" icon="code" href="/power-mode">
    Complete SOQL reference and examples
  </Card>

  <Card title="Query Builder" icon="filter" href="/query-builder">
    Use visual filters instead
  </Card>
</CardGroup>
