select max(id) from (select top n * from tablename) a

解决方案 »

  1.   

    select max(id) from (select top 10 id from 表) tmp
      

  2.   

    select max(id) 
    from (select top 10 * from 表) a
      

  3.   

    select max(id) from(select top n ... from table)
      

  4.   

    select max(id) from (select top 10 id from 表) tmp
    语句最后的tmp一定要加吗?
    是不是要加as tmp,还是as可以省略
      

  5.   

    as 可以省略 tmp 可以任意指定,但必须是标准的表名形式
      

  6.   

    谢谢 zjcxc(邹建)我自己也写了一个
    select max(id) from message where id in (select top n id from message)哪个效率高点呢