1.select top 3 * from Video where VideoID not in (select top 3 VideoID from Video order by VideoID)查询中间的数据库
借助于临时表以及一个函数来实现代码如下:Select no=Identity(int,1,1),* Into #temptable From dbo.teacher_info order by teacher_name--利用Identity函数生成记录序号Select * From #temptable Where no>=10 And no < 20Drop Table #temptable--用完后删除临时表
declare myCursor scroll cursor for select * from test open myCursor fetch absolute 3 from myCursor close myCursor deallocate myCursor
一条sql实现不了的,通过通过临时表来实现:Select no=Identity(int,1,1),* Into #temptable From dbo.mytable--利用Identity函数生成记录序号 Select * From #temptable Where no=15 Drop Table #temptable--用完后删除临时表
select top 1 * from (select top 15 * from table_name order by filed_name desc) as obj;
如果只是一条的话。select top 1 * from tablewhere 主键 not in (select top 行数-1 主键 from table )
open myCursor
fetch absolute 3 from myCursor
close myCursor
deallocate myCursor
如果要根据情况取一个指定的数据的记录。也可以使用set rowcount n,这个在代码层面指定。
Select * From #temptable Where no=15
Drop Table #temptable--用完后删除临时表