# Write a SOQL query on FieldHistory (AccountHistory or OpportunityFieldHistory) to see who changed a specific field in the last 7 days.

**Topic:** Development · **Difficulty:** Medium · **Asked at:** KPMG, Deloitte, Infosys · **Tags:** soql, scenario, field-history, audit

Read it on the site: https://www.forcechallenges.com/interview-questions/write-a-soql-query-on-fieldhistory-accounthistory-or-opportunityfieldhistory-to-see-who-changed-a-specific

## Answer

Query the history object with a date literal filter and read who changed the field via `CreatedBy`.

```soql
SELECT AccountId, Field, OldValue, NewValue, CreatedBy.Name, CreatedDate
FROM AccountHistory
WHERE Field = 'Industry' AND CreatedDate = LAST_N_DAYS:7
ORDER BY CreatedDate DESC
```
For Opportunities use `OpportunityFieldHistory` (with `OpportunityId`). Field history tracking must be enabled on the field.

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