其中 CreateTime  字段是有时间先后顺序的,谢谢各位,我一直想不出来怎么做,麻烦大家!

解决方案 »

  1.   


    select top 1 * from 表名 where id not in (select top 2 * from 表名)
      

  2.   

    select top 1 * from 表名 where id not in (select top N-1 * from 表名)--上面的语句中,N是代表第N条,用具体的数字代替N-1就得到相应的记录
      

  3.   

    select top 1 * from (select top 3 * from tb ) a order by createtime desc
      

  4.   

    select top 1 *
    from (
    select top n *   //n表示你要查询的第n条记录,比如取第3条记录,n=3
    from table
    order byu desc
    )
      

  5.   

    select top 3 * from 表
    或 select * from 表 where  name='C'
      

  6.   

    select top 1 * from ( select top 3 * from table order by createtime ) a order by createtime desc
      

  7.   

    查询N-M条记录:select IDENTITY(int,1,1) as iid,* into #temptable from yourtableselect top M-N * from #temptable where iid>=NOR:select top M-N * from yourTable where id not in(select top N-1 id from table)
    ID为表具有唯一值的任何字段
      

  8.   

    谢谢大家的回复,我已经了解了TO  yjdn(无尽天空) 
    select top 1 * from TABLE where ID not in (select top 2 * from TABLE)
    有问题,where ID not in (select top 2 * from TABLE) 在not in列表中只能指定一个字段ID,但是select top 2 * from TABLE 查出的是所有字段TO long0104() 
    select top 3 * from 表 ——查出的是前3个,而不是第3个
    或 select * from 表 where  name='C'——用name做限定条件不可取TO crazyswan(crazy) 
    select top 1 *
    from ( select top 3 *  from TABLE order by CREATETIME desc) 
    有错误
      

  9.   

    加一个别名
    select top 1 *
    from ( select top 3 *  from TABLE order by CREATETIME desc) as b
      

  10.   

    也不对
    select top 3 *  from TABLE order by CREATETIME desc取到
    6
    5
    4
    再 select top 1 * 则取到的是
    6  F    2004-9-1 17:01