select * from
(
select id, type, LISTAGG(value,',') WITHIN GROUP (ORDER BY 1) as value from
(
select 'user1' as id, 'BMW' as value, 'CAR' as type from dual union
select 'user1' as id, 'Audi' as value, 'CAR' as type from dual union
select 'user2' as id, 'Honda' as value, 'CAR' as type from dual union
select 'user1' as id, 'Dell' as value, 'COMPUTER' as type from dual union
select 'user1' as id, 'Sony' as value, 'COMPUTER' as type from dual union
select 'user2' as id, 'HP' as value, 'COMPUTER' as type from dual
)
group by id, type
)
PIVOT (max(value) FOR id IN ('user1' user1, 'user2' user2));
如果LISTAGG大于4000个字符,有没有办法使用上面的例子?
Pivot似乎不适用于CLOB列。我尝试使用带有.getClobVAl()的XMLAGG。这给了我一个大于4000但不能转动的列表。