I have a consumer table which has the columns – Email, AccountState and DateCreated
AccountState can have the values 1 (active), 2 (inactive) and 3 (archived)
A specific consumer can have multiple rows consisting of the account state’s above.
What I am trying to do is construct a query which returns the following
A. A list of consumer records for each consumer (using email address)
B. Only the records which aren’t the most recent (so if a specific email address has 3 records, 1 for each state, it would return the 2 which aren’t the most recent)
Then once I have this list I want to set all these states to 3 as they need to be archived.
So for the example data shown here

Only rows 13 – 16 would be returned.
I have tried to do this using the query below but it isn’t working.
SELECT con.Email,
con.Id,
con.DateCreated AS DateRegistered,
con.DateLastActivity,
con.hasiPhone,
con.hasAndroid,
con.hasSMS,
con.CurrencyCode AS Currency,
con.AccountState
FROM Consumer con
WHERE con.AccountState <> 1
AND DateCreated =( SELECT MAX(DateCreated)
FROM Consumer con_most_recent
WHERE con_most_recent.AccountState <> 1
AND con_most_recent.Id = con.Id)
order by Email asc
EDIT changing state for these rows