select 审批人 from table1 A
where 编号 =
(select max(编号) from table1 where 编号 <
(select min(编号) from table1 where 审批人 = 'bbb' and 编号 > A.编号))
where 编号 =
(select max(编号) from table1 where 编号 <
(select min(编号) from table1 where 审批人 = 'bbb' and 编号 > A.编号))
(select max(编号) from yourtable where 编号<(select 编号 from yourtable where 审批结果='同意' and 审批人='bbb'))
1 同意 aaa
if exists(select 审批人 from 表 where 审批人 = 'bbb' and 审批结果 = '同意'
select @cName = 审批人 from 表 where 审批人 <> 'bbb' and 审批结果 = '同意'
if @cName is null
print '不存在'
select 编号(自动增加) 审批结果 审批人 from 表 where 审批人 <> 'bbb' and 审批结果 = '同意'
(select min(编号) from table1 where 审批人 = 'bbb' and 审批结果='同意')
编号(自动增加) 审批结果 审批人 产品编号
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
from 表 tem2 where tem2.审批结果='同意' and tem1.产品编号=tem2.产品编号 and tem2.编号<(select min(编号) from 表
where 审批人='bbb' and 审批结果='同意' and 产品编号=tem2.产品编号))
编号(自动增加) 审批结果 审批人 产品编号
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不是定的。只是代表审批的人不同意的人的姓名。找出不同意时应退回的人的姓名
where 编号 =
(select max(编号) from table1 where 编号 <
(select min(编号) from table1 where 审批人 = 'bbb' and 编号 > A.编号))