2014-02-28 37 views
0

我是oracle sql中的初学者。我的脚本中有一个错误。我不知道什么是错的。我检查了可能会导致错误的一切。请帮我..sql oracle中的标识符无效

这里的脚本:

insert into antifraud(case_number,monitored_date,trigger1,trigger2,contract_number,description) 
select a.col1 as case_number, a.col2 as monitored_date 
    ,a.col3 as trigger1, a.col4 as trigger2 
    ,a.col15 as contract_number, a.col6 as description 
from (
select length(t.col2),(row_number() over (order by id)) as ord,t.* 
from app_account.params p 
inner join app_account.import_temp t on p.guid=t.reference 
order by t.id 
) a 
left join antifraud et 
on a.contract_number=et.contract_number 
and a.trigger1=et.trigger1 
and a.trigger2=et.trigger2 
and a.monitored_date=et.monitored_date 
where a.ord>3 
and et.contract_number is null; 

错误:

SQL Error: ORA-00904: "A"."MONITORED_DATE": invalid identifier 
00904. 00000 - "%s: invalid identifier" 

回答

1
and a.monitored_date=et.monitored_date 

应该

and a.col2=et.monitored_date 
+0

他提到'a.col2为monitored_date' –

+2

数据过滤后应用@NagarajS别名环和最后的'SELECT'ion。它不能在'WHERE'子句中使用,除非在外部查询中引用了别名列。所以,如Jeff所说,它必须是'a.col2' –