我正在尝试执行透视操作。枢轴工作正常。以防我想动态地传递查询而不是硬编码的值。根据pivotxml中的文档,它提供了错误。任何建议都会有帮助,
枢轴工作正常:
select * from
(select column_name from cols where table_name = 'EMPLOYEES') aa
pivot
(
max(aa.column_name)
for column_name in ('EMPLOYEE_ID', 'FIRST_NAME')
);
pivot xml引发错误:
select * from
(select column_name, table_name from cols where table_name = 'EMPLOYEES')
pivot xml
(
max(column_name)
for column_name in (select column_name from cols where table_name = 'EMPLOYEES')
);
ORA-00918: column ambiguously defined
00918. 00000 - "column ambiguously defined"
* Cause:
* Action:
尝试提供别名,但仍然没有帮助。
我们还有其他方法来定义in子句中的子查询吗
1条答案
按热度按时间iqih9akk1#
尝试使用pl/sql语句,结果与预期一致。下面是pl/sql语句,