I've got this table structure
+------+-------+--------------------------------------+
| parent_id | child_id | sdate
+------+-------+--------------------------------------+
| 59 | 1 | 2018-01-01
| 59 | 2 | 2019-01-01
| 60 | 5 | 2016-01-01
| ... | ... | ...
+------+-------+--------------------------------------+
What I need is to get the parent_id, and the child_id with the highest date for that parent_id.
If I do this query :
select parent_id, child_id, max(sdate) from my_table group by parent_id;
I get
| parent_id | child_id | max(sdate)
| 59 | 1 | 2019-01-01
| 60 | 5 | 2016-01-01
So the date is good but the child_id for the first row should be 2.