日期:2014-05-17  浏览次数:20792 次

数据缺号
请问数据库中有的记录 
0001 
0002 
0003 
0004 
0006 
0007 
0008
0009 
0012 

如何把缺号的0005和0010,0011找出来

------解决方案--------------------
SELECT m.f, b.j
FROM (SELECT TO_NUMBER (a) f
FROM a_txt) m,
(SELECT LEVEL AS j
FROM DUAL
CONNECT BY LEVEL <= 12) b
 WHERE m.f(+) = b.j AND m.f IS NULL
------解决方案--------------------
参考:
http://lastwinner.itpub.net/post/7102/260759

--------------------
select *
from
(
select rownum rn
from t
 where rownum <= 12
connect by rownum <= 12
) b
where 
b.rn not in
(
select to_number(num)
 from t a
)

/