ORA-00905:select语句中缺少关键字错误

时间:2012-10-11 07:36:58

标签: sql oracle

我在下面的选择查询中收到错误。这是我收到的错误:

  

ORA-00905:缺少关键字

有人可以帮忙吗?

SELECT ni.node_installation_id,ni.customer_node_id,ni.customer_id,c.brand_name_1,substr(nitr.name,1,instr(nitr.name, ' ')-1) as node_inst_type
    from node_installation ni , customer c , node_inst_type_release nitr
    where ( Case 
            WHEN ni.arne_timestamp is null  THEN ( case  
                                                   when ni.arne_flag ='I' then ni.arne_flag ='I'
                                                   END )
     else (trunc(sysdate) - trunc(ni.arne_timestamp) >= 60)
      end)     
and ni.customer_id = c.customer_id 
and ni.node_inst_type_release_id = nitr.node_inst_type_release_id
and ni.no_of_collection_node_missed >= 4
and c.customer_id =90;

2 个答案:

答案 0 :(得分:1)

可能问题出在case

( 
  case  
    when ni.arne_flag ='I' 
      then ni.arne_flag ='I'
  END 
)

我认为情况完全错了。尝试将其更改为:

((ni.arne_timestamp is null and  ni.arne_flag ='I')
or
(trunc(sysdate) - trunc(ni.arne_timestamp) >= 60))

如下:

    SELECT ni.node_installation_id,
           ni.customer_node_id,
           ni.customer_id,
           c.brand_name_1,
           substr(nitr.name,1,instr(nitr.name, ' ')-1) as node_inst_type
     from node_installation ni , 
          customer c , 
          node_inst_type_release nitr
   where ((ni.arne_timestamp is null and  ni.arne_flag ='I')
          or
          (trunc(sysdate) - trunc(ni.arne_timestamp) >= 60))     
    and ni.customer_id = c.customer_id 
    and ni.node_inst_type_release_id = nitr.node_inst_type_release_id
    and ni.no_of_collection_node_missed >= 4
    and c.customer_id =90;

答案 1 :(得分:0)

你的内部CASE语句对我来说是错误的,虽然我不是100%为什么它在语法上不正确:

CASE 
       WHEN ni.arne_flag = 'I' THEN **ni.arne_flag = 'I'**  END 

我认为'THEN'之后的表达式应该是一个值,但无论如何它都是多余的。