1

可能重复:
SQL SERVER 中 ORACLE 的 CONNECT BY PRIOR 模拟

--我需要将下面的 PL/SQL 转换为 SQL

SELECT  DataMapId, REPLACE((QtyType, '#'), '#') AS QtyTypes
            FROM    (
                        SELECT  DataMapId, '<QtyType>' + cast(DataTypeId as nvarchar(200)) + '</QtyType>' AS QtyType,
                                ROW_NUMBER() OVER (PARTITION BY DataMapId ORDER BY DataTypeId) AS rn
                        FROM    tblDataMapChannels
                    )
            WHERE   CONNECT_BY_ISLEAF = 1
            CONNECT BY  rn = PRIOR rn + 1
                AND     DataMapId = PRIOR DataMapId
            START WITH  rn = 1
4

0 回答 0