# Write a SOQL query to fetch all deleted Accounts currently sitting in the Recycle Bin (WHERE IsDeleted = true ALL ROWS).

**Topic:** Development · **Difficulty:** Easy · **Asked at:** Infosys, TCS, Wipro · **Tags:** soql, scenario, recycle-bin

Read it on the site: https://www.forcechallenges.com/interview-questions/write-a-soql-query-to-fetch-all-deleted-accounts-currently-sitting-in-the-recycle-bin-where-isdeleted-true

## Answer

Filter on `IsDeleted = true` and add `ALL ROWS` so the query includes Recycle Bin records. In Apex only (not Query Editor) use this syntax.

```apex
List<Account> deleted = [SELECT Id, Name, DeletedDate FROM Account WHERE IsDeleted = true ALL ROWS];
```
You can pass the results to `undelete` to restore them.

---
Source: ForceChallenges · last updated 2026-10-19
