Oracle SQL ORA-00937:不是单组组功能

use*_*955 2 sql oracle group-by function

我正在尝试搜索类型为"Savings"的帐户,但以下代码摘录给出了错误"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';
Run Code Online (Sandbox Code Playgroud)

Tim*_*ams 9

你需要一个"分组依据"条款:

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;
Run Code Online (Sandbox Code Playgroud)