查询需求:查找用户时间最晚的一条记录
SELECT temp.*, FROM (SELECT * FROM table ORDER BY date DESC) temp GROUP BY user_id
查询需求:查找用户时间最晚的两条记录
SELECT t1.* FROM table t1 WHERE (SELECT COUNT(1) FROM table t2 WHERE t1.user_id=t2.user_id AND t1.date <=t2.date)<=2 GROUP BY t1.user_id,t1.date