一点一滴,编程人生

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  69 随笔 :: 0 文章 :: 25 评论 :: 0 Trackbacks
有一个表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

希望对遇到此类问题的朋友给以启示
posted on 2011-05-11 16:11 writegull 阅读(1325) 评论(0)  编辑  收藏 所属分类: 数据库

只有注册用户登录后才能发表评论。


网站导航: