Hello.
I have to make a recursive query like this one:
Code:
WITH temptab(org_id, superior_id) AS
(
SELECT root.org_id, root.superior_id
FROM bns_org root
WHERE root.org_id IN (SELECT ... FROM ...)
UNION ALL
SELECT sub.org_id, sub.superior_id
FROM bns_org sub, temptab super
WHERE sub.superior_id = super.org_id
)
SELECT emptab.org_id FROM temptab!
Now I have to use this query in another query.
The nested query
Code:
SELECT * FROM (SELECT ... FROM ... )
is valid. But my query
Code:
SELECT * from (with temptab(org_id, superior_id) AS ( SELECT ...) select * from temptab)
is invaild. :-( How to use the WITH query in another query?