oracle中上级怎么求 oracle上亿级查询

oracle 如何寻找最顶层父类可以设计成有层级的序列号 , 最顶级找0101就可以了
noid_sjid_bjjc
000011
0010101012
00201010101013
003010101010101014
如何结构不能变 , 还是如下方式,而且当前层级是几级都不知道,就用循环吧
PS:001怎么还有上级编码1?到底顶级在哪里?
noid_sj id_bj
00112
00223
00334
v_id_bj:=4;
while v_id_sj is not null loop
selectid_sj into v_id_sj from tb where id_bj = v_id_bj;
selectid_bj into v_id_bj from tb where id_bj = v_id_sj;
end loop;
递归查找某一条件为是的上级id,oracle-sql简单做了几条数据,我这应该是没问题,只是不知道拿到你那会怎么样,有问题直接回复
测试数据
create table test
(parent_id int,
id int,
is_rp int,
name varchar2(10));
insert into test values (null,1,1,'aa');
insert into test values (1,2,1,'bb');
insert into test values (1,3,2,'cc');
insert into test values (2,4,1,'dd');
insert into test values (3,5,2,'ee');
insert into test values (4,6,2,'ff');
commit;
执行
with t as
(select test.*,level as lv from test
start with id = 6 --这个地方为输入id
connect by prior parent_id=id)
select name from t where exists
(select 1 from
(select is_rp,min(lv) lv from t where is_rp=1 group by is_rp) a
where a.is_rp=t.is_rp and a.lv=t.lv)
你运行一下看看结果
Oracle 查询列出员工的姓名及其上级的姓名select a.ename 员工名字,b.ename 上级名字 from emp a,emp b where a.mgr=b.empno( )
在oracle中检索每一位雇员的上级领导的姓名,职衔,所在部门名称 求大神怎么做 求答案select a.ename 员工名字,b.ename 上级名字,b.职衔,c.所在部门名称
from emp a,emp b,dept c where a.mgr=b.empno( ) and a.deptno=c.deptno( )
oracle 查询问题,我想查询organ_name(地区名称)和上级地区名称(我想根据parent_id自连接查询)你没有贴表名和结构代码,根据你的贴图,写了如下SQL,希望对你有帮助,如有问题可以追问,
你的表是树级的结构,有上下级关系,查询是比较容易的,用编号和用名称查没本质区别,你在套一层就可以了,
select *
from 表名 a
where a.organ_id != '3709'
start with a.organ_id ='3709'
connect by prior a.parent_id = a.organ_id
查 泰安市 的上级地区应该是 山东
求Oracle查询上下级关系语句如果是SQL2005以上则可以用CTE递归写法
use tempdb
go
create table #emp
(eid integer not null,
ename varchar(10) not null,
epid integer null,
)
insert into #emp
select 1,'A',5
union all
select 2,'me',3
union all
select 3,'bos',4
union all
select 4,'boss',null
select * from #emp
【oracle中上级怎么求 oracle上亿级查询】;with empcte as
(select epid,(select ename from #emp b where b.eid = a.epid) as name from #emp a where ename = 'me'
union all
select b.epid,(select ename from #emp where eid = b.epid) as name from empcte a join #emp b on a.epid = b.eid
)
select * from empcte where epid is not null
关于oracle中上级怎么求和oracle上亿级查询的介绍到此就结束了 , 不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

    推荐阅读