Oracle SQL ORA-00937:不是单个组函数

Oracle SQL ORA-00937:不是单个组函数,sql,oracle,function,group-by,Sql,Oracle,Function,Group By,我正在尝试搜索“储蓄”类型的帐户,但以下代码摘录给我错误“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'; 您需要一个“分组依据”条款: PS:在SELECT子句中

我正在尝试搜索“储蓄”类型的帐户,但以下代码摘录给我错误“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';
您需要一个“分组依据”条款:

PS:在SELECT子句中使用的任何列(聚合函数除外)都应该出现在GROUPBY子句中。这是一个盲目的规则

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;
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;