select max(id) from yourtable

解决方案 »

  1.   

    select max(标识列) from 表 where Name='姓名'是不是这个意思???
      

  2.   


    select count(*) from tablename --最大标识列的排列序号select max(标识列) from tablename --最大标识列
      

  3.   

    select IDENTITY(int, 1,1) AS ID_Num,* into #temp from 表 order by 姓名select * from #temp where ID_Num between 10 and 20
      

  4.   

    更正
    select identity(int,1,1) as xh ,标识列,姓名 into #temptable
       from tablename order by 姓名 select #temptable.xh,#temptable.标识列,#temptable.姓名
      from #temptable where #temptable.标识列 in 
       (select max(标识列) from tablename)drop table #temptable
      

  5.   

    select identity(int,1,1)xh,cast(标识列 as int)标识列,Name,.... into #temp from 表 order by Nameselect max(xh) from 表 where Name='姓名'
      

  6.   

    to 大力:
    但现在如果表中已有标识列,是不能通过
    select identity(int,1,1) as xh ,标识列,姓名 into #temptable
       from tablename order by 姓名
    加入第二个标识列的。
      

  7.   

    select count(*) from yourtable A 
     where 姓名 <= (select 姓名 from yourtable 
                     where id = (select max(id) from yourtable)
      

  8.   

    select count(*) from yourtable A 
     where 姓名 <= (select 姓名 from yourtable 
                     where id = (select max(id) from yourtable))
      

  9.   

    select *,identity(int,1,1) as id1 into #tmp from yourtable order by name select id1 from #tmp where id =(select max(id) from #tmp )
      

  10.   

    select sum(1) from tablename --最大标识列的排列序号
      

  11.   

    tj_dns提供了最好的解决方法。只有crazyfor提供的代码可以产生第二个标识列。
      

  12.   

    学习中。
    我感觉
    select count(*) from yourtable A 
     where 姓名 <= (select 姓名 from yourtable 
                     where id = (select max(id) from yourtable))
    是正确的。