首先保证你的表有个排序字段,假设是升序排列的select * from (select top 3 * from table order by column desc) b order by column
LS的不太好吧??如果表中的数据是135267那就不能用order by 了..
[此贴子已经被作者于2007-5-21 10:06:45编辑过]
像我说的那种情况,如果用排序的话,就不能达到要求的..
楼上的 你的返回结果肯定会有超过3的情况,你看看3楼的例子 你的结果是4条记录
设标识就是自己加条件拉,人家楼主没说这列是自增型也没说这列是主键
--可以用游标,从倒数第三行向后一行行查询。declare @a char(10)declare @b char(10)declare oneCursor scroll cursor forselect * from table2
open oneCursorfetch absolute -3 from oneCursor into @a,@b
while (@@fetch_status=0)begin print 'a=' + @a + ' b=' + @b fetch oneCursor into @a,@bend
close oneCursordeallocate oneCursor