2015-04-21 74 views
-1

當我們使用v9.1時,我工作得很好,但是在升級到v9.4後,以下失敗。PostgreSQL CASE WHEN Then ELSE END錯誤

SELECT a.account_id 
     ( 
       select round(cast(sum(WHEN c.transaction_type = 'Ranger' THEN c.original_currency ELSE c.original_currency * -1 
     end)) AS NUMERIC), 
         2) 
FROM  account_transaction AS c 
WHERE a.account_id = c.account_id 
GROUP BY c.account_id) 
AS 
    balance_amount 
    FROM account 
AS 
    a LEFT JOIN account_type 
AS 
    b ON a.account_type_id = b.account_type_id 
    WHERE ( 
    b.description >= 'Boomberang' AND b.description <= 'Boomberang' 
); 

語法錯誤或接近WHEN

我用Google搜索,但未能解決問題。請幫忙。

回答

4

看起來你缺少CASE關鍵字,試試這個來代替:

(CASE WHEN c.transaction_type = 'Ranger' THEN c.original_currency ELSE c.original_currency * -1 END) 
+0

你說得對。這個詞缺失。它應該是CASE WHEN。我很抱歉我的困惑。謝謝你指出。 –

1

您的意思是CASE WHEN而不是WHEN嗎?

+0

是的,這是不用時,WHEN。謝謝你指出。 –

相關問題