2012-04-02 22 views
2

'Savings'タイプのアカウントを検索しようとしていますが、次のコード抽出でエラーが発生しています。 "ORA-00937:グループ機能 " - なぜ誰がこのエラーを受けているのか分かりませんか?Oracle SQL ORA-00937:単一グループ・グループ機能ではありません

SELECT b.bID as "Branch Number", COUNT(a.accNum) as "# of Saving Accounts" 
from branchtable b, accounttable a 
where a.bId = b.bID 
and a.acctype = 'Savings'; 

答えて

9

あなたが "GROUP BY" 節が必要です。

SELECT b.bID as "Branch Number", 
    COUNT(a.accNum) as "# of Saving Accounts" 
from 
    branchtable b, accounttable a 
where 
    a.bId = b.bID and a.acctype = 'Savings' 
group by b.bID; 
+0

パーフェクト!ありがとう – user1308955

1
SELECT b.bID as "Branch Number", COUNT(a.accNum) as "# of Saving Accounts" 
from branchtable b, accounttable a 
where a.bId = b.bID 
and a.acctype = 'Savings' 
GROUP BY b.bID; 

PS:あなたは集約関数を除き、SELECT句で使用する列がclause.ItのA、GROUP BYで存在すべきものは何でもしますブラインドルール。

関連する問題