ERROR ORA-00904:在简单的UNPIVOT查询中。我究竟做错了什么?

时间:2016-05-26 16:20:41

标签: sql oracle11g unpivot ora-00904

对UNPIVOT列运行基本查询到行并获取“无效标识符”错误。我的代码中是否有拼写错误?

Oracle 11G

select
   1 c1, 2 c2, 3 c3
FROM
   dual t
UNPIVOT
INCLUDE NULLS (
VALUE
   FOR
      COL
   IN
   (
      c1,c2,c3
   ));

错误:

ORA-00904: "C3": invalid identifier
00904. 00000 -  "%s: invalid identifier"
*Cause:   
*Action:
Error at Line: 533 Column: 13

1 个答案:

答案 0 :(得分:2)

请重新构建您的查询...

with t as (select
   1 c1, 2 c2, 3 c3
FROM
   dual) 
select * from t 
UNPIVOT
INCLUDE NULLS (
VALUE
   FOR
      COL
   IN
   (
      c1,c2,c3
   ));