declare @tb table
(
  f1 int,f2 int
)
insert @tb
select 1,4 union all
select 2,5 union all
select 1,3 union all
select 1,5 union all
select 3,5 union all
select 1,2 union all
select 2,3--查询
select identity(int,1,1) id,* into # from @tbselect f1,f2
from # t
where f1<>1
      and exists(select 1 from # where id=t.id-1 and f1=1)drop table #--结果
/*f1          f2          
----------- ----------- 
2           5
3           5
2           3(所影响的行数为 3 行)
*/

解决方案 »

  1.   

    --建表
    create  table a
    (
      f1 int,f2 int
    )
    --测试数据
    insert a(f1,f2) values(1,4)
    insert a(f1,f2) values( 2,5)
    insert a(f1,f2) values( 1,3)
    insert a(f1,f2) values( 1,5)
    insert a(f1,f2) values( 3,5)
    insert a(f1,f2) values( 1,2)
    insert a(f1,f2) values( 2,3)--查询语句
    select f1,f2 from a where f1 <>'1'
      

  2.   

    如果是vb了可以直接用vb处理
    tag=false
    do while not rs.eof
        if tag=true then
            debug.print rs!f1
            tag=false
        end if    if rs!f1=1 then
            tag=true
        end if
        rs.movenext
    loop