# Write a SOQL query to find all AccountShare records for a specific Account to inspect manual and Apex sharing reasons (RowCause).

**Topic:** Development · **Difficulty:** Medium · **Asked at:** Deloitte, PwC, EY · **Tags:** soql, scenario, sharing, setup-objects

Read it on the site: https://www.forcechallenges.com/interview-questions/write-a-soql-query-to-find-all-accountshare-records-for-a-specific-account-to-inspect-manual-and-apex-sharing

## Answer

Each sharing-enabled object has a `Share` object (e.g. `AccountShare`) holding the sharing grants. Filter by `AccountId` and inspect `RowCause` to see why access exists.

```soql
SELECT Id, AccountId, UserOrGroupId, AccountAccessLevel, RowCause
FROM AccountShare
WHERE AccountId = :accId
```
`RowCause` values include `Owner`, `Manual`, `Rule`, `Team`, `Territory`, and Apex sharing reasons for custom objects.

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