2016-09-05 6 views
0
SELECT 
    (case TRIM(T.tactictype) 
     WHEN 'Economics' THEN 
      (select economic_tactic_id from cfext.economic_tactics E where LOWER(E.economic_tactic_name) = LOWER(T.tacticname)) 
     WHEN 'Cyber' THEN 
      (select cyber_tactic_id from cfext.cyber_tactics E where LOWER(E.cyber_tactic_name) = LOWER(T.tacticname)) 
    end) AS tacticid 
FROM cfext.banking_crreport_allfiles T 
LIMIT 50; 

私は上記のクエリを実行しようとしていますが、以下のエラーが発生しています。誰でも助けてくれますか? ParseExceptionライン4:FAILEDサブクエリで 'select'の近くの入力を認識できません。

答えて

0

表現仕様の 'から' 'economic_tactic_id' を '選択' の近くに1が入力を認識できないのハイブがでサブクエリをサポートしていません

SELECT (case TRIM(T.tactictype) WHEN 'Economics' THEN (select E.economic_tactic_id from cfext.economic_tactics E 
    where LOWER(E.economic_tactic_name) = LOWER(T.tacticname)) 
WHEN 'Cyber' THEN (select E.cyber_tactic_id from cfext.cyber_tactics E where LOWER(E.cyber_tactic_name) = LOWER(T.tacticname)) end) AS tacticid 
FROM cfext.banking_crreport_allfiles T LIMIT 50; 
0
SELECT (case TRIM(T.tactictype) 
    WHEN 'Economics' THEN 
     (select et.economic_tactic_id 
     from cfext.economic_tactics et 
     where LOWER(et.economic_tactic_name) = LOWER(T.tacticname)) 
    WHEN 'Cyber' THEN 
     (select e.cyber_tactic_id 
     from cfext.cyber_tactics e 
     where LOWER(e.cyber_tactic_name) = LOWER(T.tacticname)) 
    end) AS tacticid`enter code here` FROM cfext.banking_crreport_allfiles T LIMIT 50; 
0

を使用してみてくださいSELECT句。あなたは論理を言い換える必要があります:

SELECT COALESCE(E.economic_tactic_id, C.cyber_tactic_id) as tacticid 
FROM cfext.banking_crreport_allfiles T LEFT JOIN 
    cfext.economic_tactics E 
    ON LOWER(E.economic_tactic_name) = LOWER(T.tacticname) AND 
     TRIM(T.tactictype) = 'Economics' LEFT JOIN 
    cfext.cyber_tactics C 
    ON LOWER(C.cyber_tactic_name) = LOWER(T.tacticname) AND 
     TRIM(T.tactictype) = 'Cyber'; 
関連する問題