2009-08-07 89 views
1

単純な線形回帰をテストして、2つの重み付けセット間の最適線を求めるクエリを作成しました。これは、うまくいけば、以下のような結果を返す必要がありますが、それはOracle SQL - Strange 'ORA-00907右括弧がありません'エラー

「右括弧の欠落ORA-00907」をし、ヒキガエルはそれが言う部分に向かって指している

奇妙なエラーを投げています:

case (when trn.wid_location = 28.3 then 

私はかっこが足りないために括弧でくくってきましたが、ケースステートメントを

に置き換えた場合、それは問題ではないと思います。
100 as mine, 

エラーが表示されなくなり、クエリが実行されます。

どのような考えですか?

乾杯、

トミー

select 
     decode(wid_location,28.3,'CL',29.6,'DA') as site, 
     (n*sum_xy - sum_x*sum_y)/(n*sum_x_sq - sum_x*sum_x) as m, 
     (sum_y - ((n*sum_xy - sum_x*sum_y)/(n*sum_x_sq - sum_x*sum_x))*sum_x)/n as b 

from (
     select 
       wid_location, 
       sum(wids) as sum_x, 
       sum(mine) as sum_y, 
       sum(wids*mine) as sum_xy, 
       sum(wids*wids) as sum_x_sq, 
       count(*) as n 

     from (                  
       select 
         trn.wid_location, 
         con.empty_weight_total as wids,                  
         case ( 
           when trn.wid_location = 28.3 then con.empty_weight_total*0.900-1.0 
           when trn.wid_location = 29.6 then con.empty_weight_total*0.950-1.5 
           end     
          ) as mine 

       from widsys.train trn 
        inner join widsys.consist con 
        using (train_record_id) 

       where mine_code = 'YA' 
         and to_char(trn.wid_date,'IYYY') = 2009 
         and to_char(trn.wid_date,'IW') = 29 

           ) 

     group by wid_location 
    ) 

そして、ここでは、私が

-- +----------+--------+----------+ 
-- | SITE  | M  | B  | 
-- +----------+--------+----------+ 
-- | CL  | 0.900 | -1.0  | 
-- +----------+--------+----------+ 
-- | DA  | 0.950 | -1.5  | 
-- +----------+--------+----------+ 

答えて

5

Tは、例の構文が正しくないと思います。

SELECT last_name, commission_pct, 
    (CASE commission_pct 
    WHEN 0.1 THEN ‘Low’ 
    WHEN 0.15 THEN ‘Average’ 
    WHEN 0.2 THEN ‘High’ 
    ELSE ‘N/A’ 
    END) Commission 
FROM employees ORDER BY last_name; 
+0

すごい:

は次のように行います。今はそれが私の愚かな瞬間でした。 –

1

は、case文の両方で括弧を取り除く試して​​みてください参照させていただき結果があります。あなたはそれらを必要としません。

それができる:

case when trn.wid_location = 28.3 then con.empty_weight_total*0.900-1.0 
     when trn.wid_location = 29.6 then con.empty_weight_total*0.950-1.5 end as mine 
関連する問題