有一个表tb
id,publishTime,publishUser,其它字段
UUID,时间,张三,.....
UUID,时间,李四,.....
UUID,时间,张三,.....
现在想按照publishTime排序,排序后的结果根据publishUser字段去掉重复的记录,返回的结果集是全部字段,怎么办?
解决方案:
select * from tb t where not exists(select 1 from tb
where publishUser=t.publishUser and publishTime>t.publishTime)
order by publishTime
希望对遇到此类问题的朋友给以启示