I am trying to pick the rows based on the oldest timestamp per name. I referred this solution but the problem is my table doesn't have id column. I tried to add an temp auto increment id column but was not sure how to do it. basically when the timestamp is same I want to pick any one of the available records for the given name. Can someone please help me out here.
mysql> select * from tblemployee order by name;
+------+-------------+---------------------+
| name | day_of_week | signin_date |
+------+-------------+---------------------+
| bob | wednesday | 2017-08-11 08:11:30 |
| bob | thursday | 2017-06-11 11:21:30 | << same timestamp
| bob | saturday | 2017-08-28 09:01:30 |
| bob | wednesday | 2017-08-11 08:11:30 |
| bob | monday | 2017-06-11 11:21:30 | << same timestamp
| tom | wednesday | 2017-08-28 23:01:20 |
| tom | sunday | 2017-08-29 09:01:30 |
+------+-------------+---------------------+
My expected result would be something like this
For 'tom'
+------+-------------+---------------------+
| name | day_of_week | signin_date |
+------+-------------+---------------------+
| tom | wednesday | 2017-08-28 23:01:20 |
For 'bob' since there are two records with same timestamp , I can pick any one irrespective of day_of_week.
+------+-------------+---------------------+
| name | day_of_week | signin_date |
+------+-------------+---------------------+
| bob | thursday | 2017-06-11 11:21:30 |
(or)
| bob | monday | 2017-06-11 11:21:30 |