這是一個可以在Oracle 9i及更高版本中工作的版本。
create table foo (
key_column number,
val_column varchar2(4)
);
insert into foo values (1, 'aaaa');
insert into foo values (1, 'bbbb');
insert into foo values (1, 'cccc');
insert into foo values (2, 'dddd');
insert into foo values (2, 'eeee');
insert into foo values (2, 'ffff');
insert into foo values (2, 'gggg');
select key_column
, replace(max(sys_connect_by_path(val_column, ',')), ',') combined
from (select key_column
, val_column
, row_number() over (partition by key_column order by val_column) cur
, row_number() over (partition by key_column order by val_column) - 1 prev
from foo) foo
group by key_column
connect by prior cur = prev and prior key_column = key_column
start with cur = 1;
key_column | val_column
--------------------------
1 | aaaabbbbcccc
2 | ddddeeeeffffgggg
的可能重複的[SSIS:甲骨文多行一個輸出,而不STRAGG](http://stackoverflow.com/questions/2104527/ssis-oracle-multiple-rows-to-one-column- output-without-stragg)等 – DCookie 2011-06-10 14:54:36
不應該關閉。以上重複與歸一化形式很少複雜。 – NAVEED 2011-06-10 14:57:16
爲什麼最近所有的零散問題?每個人都在同一個班級或什麼東西? :-) – tbone 2011-06-10 15:58:52