日期:2014-05-18 浏览次数:20774 次
create table #t(id int); insert #t select 1 union select 2 union select 3 union select 4 union select 5 union select 7 union select 8 select t1.id-1 as id from (select id,row_number() over (order by id ) as num from #t)t1, (select id,row_numbe() over (order by id )+1 as num from #t)t2 where t1.num=t2.num and t1.id-t2.id>1 drop table #t
------解决方案--------------------
select a.l_id
from (select rownum l_id from dual connect by rownum <= 10000) a
where a.l_id not in (select id from a)
刚才把表名写错了,我觉得这样可以实现了,期待更好的办法。
------解决方案--------------------
select b.l_id
from (select rownum l_id from all_objects where rownum <= (select 10000 + min(id) from a)) b
where b.l_id not in (select id from a);
用聚合函数取出最小的就可以了
------解决方案--------------------