22,210
社区成员
发帖
与我相关
我的任务
分享
update temp_wsndcmdday
set send_status = '1' ,
op_time = sysdate
from temp_wsndcmdday a where a.send_status = 0 and a.op_time in
(
select op_time from
(
select send_status , op_time , row_number(order by send_time) px from temp_wsndcmdday where send_status = 0 order by send_time
) t where px <= 2
)
update temp_wsndcmdday
set send_status = '1' ,
op_time = sysdate
from temp_wsndcmdday a where exists (select 1 from
(
select * from
(
select send_status , op_time , row_number(order by send_time) px from temp_wsndcmdday where send_status = 0 order by send_time
) t where px <= 2
) b where b.send_status = a.send_status and b.op_time = a.op_time
)
select send_status,op_time into #temp from
(select send_status,op_time from temp_wsndcmdday where send_status=0 order by send_time)
where rownum <3
update #temp set send_status='1',op_time='sysdate'
update temp_wsndcmdday
set send_status='1' ,
op_time='sysdate'
from temp_wsndcmdday m where send_status = 0 and
exists (select 1 from (select send_status , op_time from temp_wsndcmdday where send_status = 0 and rownum < 3 order by send_time) n
where n.send_status = m.send_status and n.op_time = m.op_time )
请给出表结构,测试数据,相关算法和需要的结果.谢谢!