0
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 但不能旋转的列表。

4

0 回答 0