我需要进行分层查询,并且需要获得CONNECT_BY_ISCYCLE和CONNECT_BY_ISLEAF的结果,但是Oracle不支持Snowflake中的这些功能。
在雪花中无需使用它们即可实现CONNECT_BY_ISCYCLE和CONNECT_BY_ISLEAF功能的替代方法是什么?
答案 0 :(得分:1)
答案 1 :(得分:0)
是的,我去了那里。我还查看了https://docs.snowflake.net/manuals/sql-reference/constructs/connect-by.html,其中清楚地表明Snowflake不支持这些功能。 我正在尝试在代码块下面寻找替代方案,但遇到雪花错误。
person_vertex as (
select
emp_number,
user_id
from person
),
person_edges as (
select
supervisor_emp_number,
emp_number
from person
where supervisor_emp_number is not null
),
select
pv.emp_number emp_id_pk,
level,
CONNECT_BY_ROOT pv.emp_number AS root,
concat(SYS_CONNECT_BY_PATH(pv.emp_number,':'),':') as path,
-- CONNECT_BY_ISCYCLE AS iscyclic, ------------------- no idea how to implement this
-- CONNECT_BY_ISLEAF as isleaf ------------------- i tried below block, but it is not working
case
when (pe.supervisor_emp_number in (select emp_number from pv)) then 0
else 1
end AS isleaf
from person_vertex pv
left join person_edges pe on pv.emp_number = pe.emp_number
connect by prior A.emp_number = A.supervisor_emp_number
start with A.supervisor_emp_number is null
在此方面提供的任何帮助都非常感谢。
谢谢。
enter code here