日期:2014-05-18  浏览次数:20348 次

请教sql查询问题,为每个objectGuid选出最新更新的两条记录
有一张表 table1 主要的字段如下:
guid 标识主键
objectGuid 所属对象 外键
updateTime 更新时间

现需要在这个表中为每一个objectGuid选出最新updateTime的两条记录

敬请赐教


------解决方案--------------------
SQL code
select * from tb t
where updateTime in 
(
select top 2 updateTime from tb where objectGuid =t.objectGuid  order by updateTime desc)