I have multiple rows with a parent ID that associates related rows. I want to select the email address where Status = 'active', for the parent ID, and if there's multiple rows with that condition, I want to pick the most recently modified (createDate).
Basically I have two+ records, parent ID 111. The first record has m@x.com with a status of 'active', and the second record has m@y.com with a status of 'unsubscribed'. How do I select just ID 111 with m@x.com?
How would I go about this?
Table Data:
ID ParentID Email Status CreateDate
1000919 1000919 xxx@gmail.com bounced 2/5/18
1017005 1000919 yyy@gmail.com active 1/6/18
1002868 1002868 sss@gmail.com active 12/31/17
1002868 1002868 www@gmail.com active 12/31/17
1002982 1002982 uuu@gmail.com held 2/7/18
1002982 1002982 iii@gmail.com held 2/7/18
1002990 1002990 ooo@gmail.com active 10/26/18
1003255 1003255 ppp@gmail.com active 2/7/18
Expected Result:
ParentID Email Status CreateDate
1000919 yyy@gmail.com active 1/6/18
1002868 sss@gmail.com active 12/31/17