查询结果group by uid,同一个uid选择id最大那条记录
mysql> select * from test_group;
+----+-----+--------+---------+
| id | uid | sn | created |
+----+-----+--------+---------+
| 1 | 1 | NUM-01 | 123450 |
| 2 | 2 | NUM-02 | 123451 |
| 3 | 1 | NUM-03 | 123452 |
| 4 | 2 | NUM-04 | 123453 |
| 5 | 1 | NUM-05 | 123454 |
| 6 | 1 | NUM-06 | 123455 |
| 7 | 1 | NUM-07 | 123456 |
| 8 | 3 | NUM-08 | 123457 |
| 9 | 3 | NUM-09 | 123458 |
+----+-----+--------+---------+
9 rows in set (0.05 sec)
select s.*
from (SELECT max(id) as id FROM `test_group` group by `uid`) t
left join `test_group` as s on t.id=s.id
+------+------+--------+---------+
| id | uid | sn | created |
+------+------+--------+---------+
| 7 | 1 | NUM-07 | 123456 |
| 4 | 2 | NUM-04 | 123453 |
| 9 | 3 | NUM-09 | 123458 |
+------+------+--------+---------+
3 rows in set (0.00 sec)