我想从一个table里取指定行的数据,比如说我只取第15行的数据,
请问这样的sql怎么写?

解决方案 »

  1.   

    select TOP 行数 * from table
      

  2.   

    1.select top 3 * from Video where VideoID not in (select top 3 VideoID from Video order by VideoID)查询中间的数据库
      

  3.   

    借助于临时表以及一个函数来实现代码如下: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--用完后删除临时表
      

  4.   

    declare myCursor scroll  cursor for select * from  test
    open myCursor
    fetch  absolute  3  from  myCursor 
    close myCursor
    deallocate myCursor
      

  5.   

    使用Top N(一个具体的数据),可以返回指定的记录,但是这个数字必须为一个具体的常量而不能使变量。
    如果要根据情况取一个指定的数据的记录。也可以使用set rowcount n,这个在代码层面指定。
      

  6.   

    一条sql实现不了的,通过通过临时表来实现:Select no=Identity(int,1,1),* Into #temptable From dbo.mytable--利用Identity函数生成记录序号 
    Select * From #temptable Where no=15
    Drop Table #temptable--用完后删除临时表 
      

  7.   

    select top 1 * from (select top 15 * from table_name order by filed_name desc) as obj;
      

  8.   

    如果只是一条的话。select top 1 * from tablewhere 主键 not in (select top 行数-1 主键 from table )