How to group by and get the latest record with column combination

i have a node with few columns and below are few of the results in it

Email1 Email2 ContactDateInStr 20190604 20190512 20190604 20190515

The result should be below where i am considering combination of Email1 and Email2 and taking only latest date(string) .

Email1 Email2 ContactDateInStr 20190604 20190604 20190515

any suggestion?

Yes, after the match, after you've projected out variables, just use the max() aggregation.

WITH email1, email2, max(contactDateInStr) as latestDate

Aggregations are with respect to the non-aggregation variables which become the grouping key, so this is the max contact date string per each distinct email1, email2 combination.

1 Like

Yes , this would work if i just need the combination and max of date. Thanks!