We have many cases where customers are submitting multiple support cases via our website for the same issue. We would like to identify the latest case submitted per customer and automatically close the remaining cases for that customer (identified by web email).

Is there a SOQL that can be written to retrieve the last case submitted grouped by web email ? THanks.

  • What is web Email ? Is it the email of the customer or something else ?
    – Amit Sahu
    May 4, 2020 at 15:15
  • yes, this is the email of the customer that is submitted on the web form.
    – Paul
    May 4, 2020 at 15:44

1 Answer 1


You can have a soql query like below -

list<aggregateresult> agr = [select id,suppliedemail, MAX(CreatedDate) from case group by id, suppliedemail];

I assume you want to group by web email standard case field.

You must log in to answer this question.

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