select * from 表
where id not in (select top 1 id from 表 order by id asc)

解决方案 »

  1.   

    select top 1 * from (select top 2 * from 表) order by id DESC
      

  2.   

    :)
    select top 1 * from (select top 2 * from tb_dd) a order by id DESC
      

  3.   

    Please try it:(已测试通过)select  kk.* 
    from (select  top 1 * from table)gg , (select  top 2 * from table) kk
    where  gg.id!=kk.id
      

  4.   

    --测试数据
    create table ta(id int, name varchar(10))
    insert ta select 1, '张锦' union all select 2, '张锦'
    union all select 3, '张锦' union all select 4, '李强'
    --查询
    select top 1 *
    from (select top 2 *
          from ta
          where name='张锦')a
    order by id desc
    /*
    select top 1 *
    from ta
    where id not in(
          select top 1 id
          from ta
          where name='张锦')
    */
    --清除
    drop table ta
      

  5.   

    select top 1 * from table where id not in ( select top 1 id from table )
      

  6.   

    select top 1  * from table1 where id <5  and id not in 
    (select top 1 id from table1)
      

  7.   

    还要带条件的。比如查询姓名="在" 和推荐与审核为真的第二条记录
    怎样用一条sql语句查询出表里的第二条记录。
    select top 2 * into #aa where 姓名='在' and 推荐='t' and 审核='t'  order by id descselect top 1 * from #aa 
      

  8.   

    或才select top 2 * into #aa where 姓名='在' and 推荐='t' and 审核='t'  order by id descselect * from (select top 1 * from #aa ) t ,(select top 2 * from #aa) g
    whre g.id<>t.id
      

  9.   

    SELECT TOP 2 *
    FROM T_WenZhang
    ORDER BY WZ_Time DESC
      

  10.   

    错了,还是应该是
    select top 1 * from T_WenZhang where WZ_Class='社区通告' and (Wz_id NOT IN (SELECT TOP 1 Wz_id FROM T_WenZhang  where WZ_Class='社区通告' ORDER BY WZ_time))
      

  11.   

    select top 1 * from 表
    where id not in (select top 1 id from 表 order by id asc)
      

  12.   

    select top 1 * from 表 where [id] not in(select top 1 [id] from 表)
      

  13.   

    select top 2 from tablename
    where field not in (select top 1 id from 表 order by id asc)
      

  14.   

    select top 2 from tablename
    where field not in (select top 1 id from tablename order by id asc)