select 审批人 from table1 A
where 编号 = 
(select max(编号) from table1 where 编号 < 
  (select min(编号) from table1 where 审批人 = 'bbb' and 编号 > A.编号))

解决方案 »

  1.   

    select top 1 * from yourtable where 审批人='aaa' and 审批结果='同意'
      

  2.   

    select * from yourtable where 编号=
    (select max(编号) from yourtable where 编号<(select 编号 from yourtable where 审批结果='同意' and 审批人='bbb'))
      

  3.   

    select * from 表 where 编号=(select max(编号) from 表 where 审批结果='同意' and 编号<(select min(编号) from 表 where 审批人='bbb' and 审批结果='同意'))
      

  4.   

    不是的我只要一条就行了
    1       同意    aaa
      

  5.   

    declare @cName varchar(50)
    if exists(select 审批人 from 表 where 审批人 = 'bbb' and 审批结果 = '同意'
       select @cName = 审批人 from 表 where 审批人 <> 'bbb' and 审批结果 = '同意'
    if @cName is null
     print '不存在'
      

  6.   

    if exists(select 审批人 from 表 where 审批人 = 'bbb' and 审批结果 = '同意'
       select 编号(自动增加) 审批结果  审批人 from 表 where 审批人 <> 'bbb' and 审批结果 = '同意'
      

  7.   

    select top 1 * from yourtable where 审批人<>'bbb' and 审批结果='同意' and 编号 < 
      (select min(编号) from table1 where 审批人 = 'bbb' and 审批结果='同意')
      

  8.   

    表如下
    编号(自动增加)   审批结果  审批人 产品编号
       1       同意    aaa   1
          2              同意    bbb   1
          3              不同意   ccc   1
          4              同意    bbb   1
          5              不同意   ccc   1
          6              不同意   bbb   1
       7       同意    aaa   2
          8              同意    bbb   2
          9             不同意   ccc   2
          10              同意    bbb   2
          11              不同意   ccc   2
          12              不同意   bbb   2  
    要找到bbb同意的前一个人同意的人aaa什么找???
      编号(自动增加)   审批结果  审批人 产品编号
       1       同意    aaa   1
       7       同意    aaa   2
      

  9.   

    select * from 表 tem1 where tem1.编号=(select max(tem2.编号) 
    from 表 tem2 where tem2.审批结果='同意' and tem1.产品编号=tem2.产品编号 and tem2.编号<(select min(编号) from 表 
    where 审批人='bbb' and 审批结果='同意' and 产品编号=tem2.产品编号))
      

  10.   

    表如下
    编号(自动增加)   审批结果  审批人 产品编号
       1       同意    aaa   1
          2              同意    bbb   1
          3              不同意   ccc   1
          4              同意    bbb   1
          5              不同意   ccc   1
          6              不同意   bbb   1
       7       同意    aaa   2
          8              同意    bbb   2
          9             不同意   ccc   2
          10              同意    bbb   2
          11              同意     ccc   2
          12              不同意   ddd  2  
    要找到bbb同意的前一个人同意的人aaa什么找???
      编号(自动增加)   审批结果  审批人 产品编号
       1       同意    aaa   1
       11       同意    ccc   2bbb不是定的。只是代表审批的人不同意的人的姓名。找出不同意时应退回的人的姓名
      

  11.   

    select 审批人 from table1 A
    where 编号 = 
    (select max(编号) from table1 where 编号 < 
      (select min(编号) from table1 where 审批人 = 'bbb' and 编号 > A.编号))