select top 1 * from table where id in (select top n id from table ) order by id desc

解决方案 »

  1.   

    select identity(int,1,1) as id ,* into#ttt
    from tablename
    ----------------------------------
    select * from #ttt
    id 可以满足你
      

  2.   

    select identity(int,1,1)id,* into #temp from table
    select id from #temp where 条件等于你要的记录.
      

  3.   

    那你的记录中有不重复的字段吗?
    如果没有的话,就没办法了.如果有的话,假设此字段名为:编号
    select count(*) as 记录号 from tbname where 编号='你检索出的那条记录的编号'
      

  4.   

    我想问一下,后两位中的into #temp 是建立一个临时表吧,这样对性能是否有影响,是不是运行一下就建立一个表呢?这样的标什么时候删除?请指教
      

  5.   

    查询完了就可以删除了drop table #temp