有一個表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
希望對遇到此類問題的朋友給以啟示