简体   繁体   中英

Oracle error - Invalid Identifier (904)?

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

This is my code - I get an error: "ORA-00904" "RN":Invalid Identifier

??

What if you alias your derived table:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM