-2

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

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;
4

2 回答 2

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;
于 2012-10-11T07:47:08.683 回答
0

您的内部 CASE 语句在我看来是错误的,尽管我不是 100% 为什么它应该在语法上不正确:

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

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

于 2012-10-11T07:48:04.297 回答