0
我已經在這一段時間擱淺了一段時間。 我試圖檢索VARRAY中的值,並在另一個值下查詢它到同一行,在這種情況下,遊戲的標題,請參閱下面的更多信息。該表是目前這樣的(我已經採取了很多的屬性進行簡化它)輸出VARRAY結果到1行
CREATE TYPE Publisher_Type AS OBJECT
(PublisherName VARCHAR2(30))
/
CREATE TABLE Publisher_Table of Publisher_Type
/
INSERT INTO Publisher_Table
VALUES ('EA')
/
CREATE OR REPLACE TYPE Genre_Game AS OBJECT
(Genre VARCHAR(20))
/
CREATE OR REPLACE TYPE Genre_Type AS VARRAY(3) OF Genre_Game
/
CREATE OR REPLACE TYPE Game_Type AS OBJECT
(Title VARCHAR2(50),
GamePublisher REF Publisher_Type
GameGenre Genre_Type)
/
CREATE Game_Table of Game_Type
/
INSERT INTO Game_Table
VALUES('Madden 17', (SELECT REF(c) FROM Publisher_Table WHERE
c.PublisherName = 'EA'), (Genre_Type(Genre_Game('Sports'),
Genre_Game('Simulation'), Genre_Game('Football')))
下面就是我從網上閱讀一些職位嘗試,但它只是將無法正常工作。我的理想輸出 勁爆17 EA體育,模擬,足球
SELECT title , m.GamePublisher.PublisherName,
max(decode(rn, 1, GameGenre)) genre1,
max(decode(rn, 2, GameGenre)) genre2,
max(decode(rn, 3, GameGenre)) genre3
FROM (
SELECT title, m.GamePublisher.PublisherName, f.*,
row_number() over (partition by title order by GameGenre) rn
FROM Game_Table m, table(m.GameGenre) f
WHERE title = 'Madden 17'
)
group by title