0

I want to query records where a field value remain unchanged in an year. For Example query all accounts where status field was not changed in 2020.

If I query account history it will give me all the records for changed value in the field.

0

1 Answer 1

2

You can actually do a join on history tables. So this ask is pretty simple.

SELECT ...
FROM Account
WHERE Id NOT IN (
    SELECT AccountId
    FROM AccountHistory
    WHERE Field = 'Status'
    AND CreatedDate = LAST_YEAR
)
1
  • Hi Adrian, I thought of doing so but here is the catch For example : An account was in 'Active' status in 2020 and it became inactive in 2021. Now such accounts should show up in my list but when I add Status = Active in my query the record won't be pulled. I have exported all records for now and doing analysis in excel. Thanks for your inputs.
    – C0DEPirate
    Jun 8, 2021 at 21:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .