有一個(gè)表tb
id,publishTime,publishUser,其它字段
UUID,時(shí)間,張三,.....
UUID,時(shí)間,李四,.....
UUID,時(shí)間,張三,.....
現(xiàn)在想按照publishTime排序,排序后的結(jié)果根據(jù)publishUser字段去掉重復(fù)的記錄,返回的結(jié)果集是全部字段,怎么辦?
解決方案:
select * from tb t where not exists(select 1 from tb
where publishUser=t.publishUser and publishTime>t.publishTime)
order by publishTime
希望對(duì)遇到此類問(wèn)題的朋友給以啟示