WITH SUBQUERY AS (
SELECT
ORGID
FROM
OM_ORGANIZATION
WHERE
PARENTORGID = 'ROOT' UNION ALL SELECT
B.ORGID
FROM
SUBQUERY A,
OM_ORGANIZATION B
WHERE
B.PARENTORGID = A.ORGID
) SELECT DISTINCT
*
FROM
SUBQUERY
WITH SUBQUERY AS (
SELECT
ORGID
FROM
OM_ORGANIZATION
WHERE
PARENTORGID = 'ROOT' UNION ALL SELECT
B.ORGID
FROM
SUBQUERY A,
OM_ORGANIZATION B
WHERE
B.PARENTORGID = A.ORGID
) SELECT DISTINCT
*
FROM
SUBQUERY