( select *,row_number()over(partition by ID order by getdate()) as num from tbl ) select *from t where num=((select num from t where id='xxx')-1) and num=((select num from t where id='xxx')+1)
------解决方案-------------------- 用row_number() over (order by getdate()) 生成一个序号就ok了。
------解决方案-------------------- order by getdate() 无异于随便取两条 没多大实际意义
------解决方案--------------------