日期:2014-05-17  浏览次数:20951 次

查询除第一条纪录外的前四条纪录。
查询除第一条纪录外的前四条纪录:
select Top 4 * from news where id not in(select top 1 * from news order by id desc) order by id desc


我这样写好像不对。没有输出数据!请问应该怎么写?

------解决方案--------------------
如果是SQL2005数据库可以这么写 select top 4 * from (select row_number() over(order by id desc ) as rowid,* from [table]) as t where rowid between 2 and 4

还有一种就是先读出前五条数据 然后忽略第一条:
do while not rs.eof
a =a+1
if a>1 then
.....
end if
rs.movenext
loop
a = 0