2015-09-04 73 views
0

我有甲骨文查詢:錯誤時查詢甲骨文:不是單組分組函數

SELECT count(*),SUM(price) as total_price, 
    (SELECT count(*) as total_card_success FROM Card_trans WHERE status = 4) 
FROM Card_trans; 

執行時,它顯示錯誤:

ORA-00937: not a single-group group function 
00937. 00000 - "not a single-group group function" 

如何解決這個概率。由於

回答

2

如果你只是想在那裏算status = 4

SELECT count(*), 
     SUM(price) as total_price, 
     SUM(CASE WHEN status = 4 
       THEN 1 
       ELSE 0 
      END) some_alias 
    FROM Card_trans; 
+0

它工作的行數。非常感謝你 – user1222893