mysql group by 组内排序
SELECT * FROM (
SELECT MAX(id) AS t,wukong_uid, 1 AS tag FROM toutiao_uid_gathered_wukong GROUP BY wukong_uid
UNION ALL
SELECT id AS t ,wukong_uid, 2 AS tag FROM toutiao_uid_gathered_wukong
) AS tab ORDER BY wukong_uid ASC , t ASC ;
验证group by原理 是否来源同一行数据
SELECT * FROM (
SELECT MAX(id) AS t,wukong_uid, 1 AS tag,time_script FROM xmt_star_helper_toutiao_uid_gathered_wukong GROUP BY wukong_uid
UNION ALL
SELECT id AS t ,wukong_uid, 2 AS tag,time_script FROM xmt_star_helper_toutiao_uid_gathered_wukong
) AS tab ORDER BY wukong_uid ASC , t ASC ;
5914 10301285240 2 1516248413
65631030128524021516264338
67671030128524021516264338
77741030128524021516264338
77741030128524011516193381
3761049956411221516193381
45651049956411221516248413
50191049956411221516248413
55341049956411221516248413
64251049956411221516264338
68791049956411221516264338
73941049956411221516264338
79771049956411221516264338
79771049956411211516193381
3601081848984121516193381
3601081848984111516193381