我有表格,我正在跟踪部门和预算中心之间的关联。该协会是多对多的。现在我想只显示那些与其关联的预算中心超过10个的部门。所以我的查询应该是这样的
select dept,
count(budget_centers) as bcCount
from myTable
where bcCount > 10
group by dept
现在oracle会给出一个错误说" bcCount"是无效的标识符。有没有办法重新定义oracle
中可接受的查询答案 0 :(得分:5)
那是having
条款的用途:
select dept,
count(budget_centers) as bcCount
from myTable
group by dept
having count(budget_centers) > 10
以下是手册的相关部分:
答案 1 :(得分:2)
试试这个
select dept,
count(budget_centers) as bcCount
from myTable
group by dept
having count(budget_centers) > 10