有一个表tbid,publishTime,publishUser,其它字段UUID,时间,张三,.....
UUID,时间,李四,.....
UUID,时间,张三,.....现在想按照publishTime排序,排序后的结果根据publishUser字段去掉重复的记录,返回的结果集是全部字段,怎么办?

解决方案 »

  1.   

    select tb.* from tb join (
    select id,max(publishTime) from tb
    ) b on tb.id=b.id
      

  2.   

    select * from tb a 
     where not exists(select 1 from tb 
                     where publishUser=a.publishUser and publishTime>a.publishTime)
      

  3.   

    select * from tb join (
    select id,max(publishTime) from tb
    ) b on tb.id=b.id order by tb.publishTime
      

  4.   


    select * from tb t where not exists(select 1 from tb 
                     where publishUser=t.publishUser and publishTime>t.publishTime)
    order by publishTime