Suppose having data in table tbl:
c_id id date
251 215682 2016-12-23 11:57:57
251 218596 2017-03-28 14:08:59
251 230756 2019-12-28 16:09:20
254 254 2017-12-28 16:09:20
254 391849 2019-09-16 15:48:54
254 431331 2019-09-16 15:48:54
I expect to get:
c_id, id, date
251 230756 2019-12-28 16:09:20
254 391849 2019-09-16 15:48:54
There is also one thing to notice. There can be rows with the duplicated dates for there same c_id. For example, in the case of c_id = 254. There is no difference which one to return or we can return the one with bigger id, but it is not the problem of this question.
Here is the SQL fiddle page http://sqlfiddle.com/#!9/e7bc37/1
How to achieve that in mysql 5.7?