oracle sql 开发人员:00904. 00000 - “%s:无效标识符”。我的错在哪里?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23548568/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 01:50:48  来源:igfitidea点击:

oracle sql developer: 00904. 00000 - "%s: invalid identifier". Where is my fault?

sqloracleoracle-sqldeveloper

提问by user3617496

I am trying find my fault. I am getting this error message:

我试图找出我的错。我收到此错误消息:

SQL-Fehler: ORA-00904: "S1"."PARTNO": ungültiger Bezeichner 00904. 00000 - "%s: invalid identifier"

SQL-Fehler: ORA-00904: "S1"."PARTNO": ungültiger Bezeichner 00904. 00000 - "%s: invalid identifier"

I have checked my database and all tables exist.

我检查了我的数据库并且所有表都存在。

Here is my sql code:

这是我的sql代码:

select s1.*
 , p.city as "Produktionsort" 
 , p.partname
from (select count(s.partno) as "Anzahl_Produktarten"
        , s.partno as "Partno" 
      from company.supp_part_job s 
      group by s.partno ) s1
 , company.part p 
where s1.partno IN (select p1.partno from company.part p1 where p1.city != 'London') 
   and p.partno = s1.partno 
group by s1.partno

回答by A.B.Cade

Because you aliased in the inner select (s1) partnoas "Partno"you must refer to it as case sensitive in the outer query:

因为您在内部选择 (s1) 中设置了别名,partno因为"Partno"您必须在外部查询中将其称为区分大小写:

select s1.*
 , p.city as "Produktionsort" 
 , p.partname
from (select count(s.partno) as "Anzahl_Produktarten"
        , s.partno as "Partno" 
      from company.supp_part_job s 
      group by s.partno ) s1
 , company.part p 
where s1."Partno" IN (select p1.partno from company.part p1 where p1.city != 'London') 
   and p.partno = s1."Partno" 
group by s1."Partno"

回答by Glenn

If you put double quotes around a column name, it will make it case sensitive. So I would think this line:

如果在列名周围加上双引号,它会区分大小写。所以我认为这一行:

s.partno as "Partno" 

is creating a case-sensitive s1."Partno" but the whereclause is looking for s1.partno. Try removing the double quotes from your column aliases.

正在创建区分大小写的 s1."Partno" 但该where子句正在寻找 s1.partno。尝试从列别名中删除双引号。