注册

with RECURSIVE 用法协助

一岁就可帅了 2024/09/10 1025 6 已解决

为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:DM Database Server 64 V8
【操作系统】:win11
【CPU】:12th Gen Intel(R) Core(TM) i7-12700H
【问题描述】*:我在适配达梦数据库时出现了 -2267: 第41 行附近出现错误:递归 WITH 子句必须具有列别名列表 的报错信息,还请协助看下,另有没有qq或者微信技术支持群,麻烦发一下,我加一下,多谢,以下是我的sql内容
with RECURSIVE tmp as
( select org_name as org_name,
org_id as org_id,
parent_org_id as parent_org_id, (select count(DISTINCT u.user_id)
from hmc.mp_app_user_88881000 u
left join hmc.mp_tenant_staff_88881000 s
on u.user_id=s.staff_id
left join hmc.mp_tenant_organization_88881000 o
on o.org_id=s.org_id
left join hmc.mp_app_device_88881000 d
on u.device_id=d.device_id
where u.user_id is not null
and u.user_id !=''
and u.app_id ='afe700ea-48e5-46f1-8a7a-380ea9f4bb41'
and o.org_path like concat((select org_path
from hmc.mp_tenant_organization_88881000
where org_id=_org.org_id),'%') ) as download_count
from hmc.mp_tenant_organization_88881000 as _org
where org_id = 'root'
union all
select org.org_name,
org.org_id,
org.parent_org_id, (select count(DISTINCT u.user_id)
from hmc.mp_app_user_88881000 u
left join hmc.mp_tenant_staff_88881000 s
on u.user_id=s.staff_id
left join hmc.mp_tenant_organization_88881000 o
on o.org_id=s.org_id
left join hmc.mp_app_device_88881000 d
on u.device_id=d.device_id
where u.user_id is not null
and u.user_id !=''
and u.app_id ='afe700ea-48e5-46f1-8a7a-380ea9f4bb41'
and o.org_path like concat((select org_path
from hmc.mp_tenant_organization_88881000
where org_id=org.org_id),'%') ) as download_count
from hmc.mp_tenant_organization_88881000 as org
join tmp
on org.parent_org_id = tmp.org_id
)
select * from tmp

回答 0
暂无回答
扫一扫
联系客服