欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

orcle递归查询(START WITH) orcle递归seart with 

程序员文章站 2022-06-23 20:50:26
...

SELECT DISTINCT                

       ORGANIZATION_ID AS ID,

       ORGANIZATION_NAME AS TEXT,

       NVL (PARENT_ID, 0) AS PID,

       '' AS PS,

       '' AS PN,

       '' AS POST,

       '' AS XB

        FROM

            TE_ORGANIZATION CONNECT BY PRIOR PARENT_ID = ORGANIZATION_ID START WITH ORGANIZATION_ID IN (

           SELECT

                A .ORGANIZATION_ID

           FROM

               TE_CUSTOMER A,

               TR_PLATFORM_CUSTOMER B

           WHERE

           A.DEL_FLAG='0'

           AND A .ORGANIZATION_ID IS NOT NULL

           AND A .CUSTOMER_ID = B.CUSTOMER_ID

           AND B.PLATFORM_ID = 2

            )

        AND DEL_FLAG = 0

   ORDER BY CAST(ID AS INT)