有一个表tbid,publishTime,publishUser,其它字段UUID,时间,张三,.....
UUID,时间,李四,.....
UUID,时间,张三,.....现在想按照publishTime排序,排序后的结果根据publishUser字段去掉重复的记录,返回的结果集是全部字段,怎么办?
UUID,时间,李四,.....
UUID,时间,张三,.....现在想按照publishTime排序,排序后的结果根据publishUser字段去掉重复的记录,返回的结果集是全部字段,怎么办?
select id,max(publishTime) from tb
) b on tb.id=b.id
where not exists(select 1 from tb
where publishUser=a.publishUser and publishTime>a.publishTime)
select id,max(publishTime) from tb
) b on tb.id=b.id order by tb.publishTime
select * from tb t where not exists(select 1 from tb
where publishUser=t.publishUser and publishTime>t.publishTime)
order by publishTime