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

oracle怎么查询断层之间数据?
比如说id 3 和id 5 怎么找出他们间断层的数据id 4 ?不好意思是面试中问到的,实在是想不出怎么查询,
请有 oracle 工作经验的朋友帮忙分析下,谢谢

------解决方案--------------------
SQL code

select t.* from
(select  row_number() over (order by OBJECT_ID desc nulls last) as row_number from DBA_OBJECTS ) t where t.row_number <=(select max(id) from test)
minus
SELECT A.id FROM test A

------解决方案--------------------
SQL code

---看从这里可以收到启发不。。。家里没数据库。。没测
---Example(实现了日期的自动增长): 
select id 
from tableName start with id = 3 connect by id <5

------解决方案--------------------

select t.* from
(select row_number() over (order by OBJECT_ID desc nulls last) as row_number from DBA_OBJECTS ) t where t.row_number <=(select max(id) from tablename)
minus
SELECT A.id FROM tablename A

------解决方案--------------------
sql code
select id 
from tableName start with id = 3 connect by id <5