SELECT
IT_ID,
Max(SUBSTR (SYS_CONNECT_BY_PATH (grp , ','), 2)) GROUPS
FROM (
SELECT
U.IT_ID,
LAST_NAME,
BFIRST_NAME,
GRP,
ROW_NUMBER() OVER (partition by u.it_id ORDER BY U.IT_ID) rn,
COUNT(*) OVER() cnt
FROM ECG_IT_USERS U
JOIN SECUREGROUPS G ON U.IT_ID = G.IT_ID)
START WITH rn = 1
CONNECT BY rn = PRIOR rn + 1 and it_id = prior it_id
Group by it_id
这是我的代码 - 我收到错误: “ORA-00904”“RN”:无效的标识符
...
答案 0 :(得分:1)
如果您对派生表进行别名该怎么办:
SELECT
IT_ID,
Max(SUBSTR (SYS_CONNECT_BY_PATH (grp , ','), 2)) GROUPS
FROM (
SELECT
U.IT_ID,
LAST_NAME,
BFIRST_NAME,
GRP,
ROW_NUMBER() OVER (partition by u.it_id ORDER BY U.IT_ID) rn,
COUNT(*) OVER() cnt
FROM ECG_IT_USERS U
JOIN SECUREGROUPS G ON U.IT_ID = G.IT_ID) DT1
START WITH dt1.rn = 1
CONNECT BY dt1.rn = PRIOR dt1.rn + 1 and dt1.it_id = prior dt1.it_id
Group by dt1.it_id