I have following table,
----------------------------------------
|person_id date pstatus px1 |
----------------------------------------
1 29|6|2016 null 089E
1 27|6|2016 Died null
2 29|6|2016 null DFWE
2 27|6|2016 null WEWE
3 29|6|2016 Died null
From the above table, I need to get following output. If "pstatus" is not null I need to fetch that record corresponding to each person_id, if pstatus null , need to fetch record with latest date.
----------------------------------------
|person_id date pstatus px1 |
----------------------------------------
1 27|6|2016 Died null
2 29|6|2016 null DFWE
3 29|6|2016 Died null