假設,我們有這樣的查詢:ORA-00904:在嵌套子查詢中無效的標識符
SELECT
tt.id first_column,
tt.value second_column,
--another values
qq.code_1 third_column,
qq.code_2 column4,
qq.code_3 column5,
qq.code_4 column6,
qq.code_5 column7
FROM
test_tbl tt LEFT JOIN
(SELECT * FROM (
SELECT id, code_value, ROW_NUMBER() OVER (ORDER BY code_value) AS RN
FROM attributes attr WHERE attr.id = tt.id AND
attr.code IN ('ATTRIBUTE_CODE_1',
'ATTRIBUTE_CODE_2',
'ATTRIBUTE_CODE_3',
'ATTRIBUTE_CODE_4',
'ATTRIBUTE_CODE_5')
)
PIVOT (MAX(code_value) FOR (RN) IN (1 as code_1, 2 as code_2, 3 as code_3, 4 as code_4, 5 as code_5))) qq
ON tt.id = qq.id
-- LEFT JOINS with another tables...
的問題是錯誤:
ORA-00904: "TT"."ID": invalid identifier
我怎樣才能繞過這個障礙?
當然上面的例子很容易和虛擬,真正的查詢比較複雜。
這個例子可以在這裏檢查:http://sqlfiddle.com/#!4/eec83/3
不幸的是,這不是有效的其他數據。看看這個:http://sqlfiddle.com/#!4/ac236d/2 –
你可以請示例輸出? –