我不知道你提供了什麼樣的數據,或者你想要什麼。也許如果您發佈的查詢的解碼版本返回您正在查找的數據和/或源數據的定義,我們可以更好地回答您的問題。這樣的事情將是有益的:
create table something (somethingId Number(3), displayOrder Number(3)
, splitID Number(3));
insert into something values (1, 1, 10);
insert into something values (2, 1, 11);
insert into something values (3, 1, 12);
insert into something values (4, 1, 13);
insert into something values (5, 2, 14);
insert into something values (6, 2, 15);
insert into something values (7, 2, 16);
create table split (SplitID Number(3), SplitName Varchar2(30));
insert into split values (10, 'Bob');
insert into split values (11, 'Carrie');
insert into split values (12, 'Alice');
insert into split values (13, 'Timothy');
insert into split values (14, 'Sue');
insert into split values (15, 'Peter');
insert into split values (16, 'Adam');
SELECT *
FROM (
SELECT somethingID, displayOrder, so.SplitID, sp.splitname
FROM SOMETHING so JOIN SPLIT sp ON so.splitID = sp.SplitID
)
PIVOT (MAX(splitId) id, MAX(splitName) name
FOR (displayOrder, displayOrder) IN ((1, 1) AS split, (2, 2) as splitname)
);
來吧,有沒有是或否的答案?我在Oracle SQL的錯誤論壇上? – orbfish 2010-07-08 14:41:24
直到創建了http://area51.stackexchange.com/proposals/4260/databases或http://area51.stackexchange.com/proposals/6223/oracle-databases,您才能找到合適的位置。 – 2010-11-09 15:05:41
不幸的是,PIVOT在Oracle中是非常新的,似乎這裏的大多數人都不知道回答你的問題。你如何嘗試發佈到forums.oracle.com?更多的Oracle專家去那裏比來這裏。 – 2010-11-09 15:14:18