我在 Oracle SQL 中有两个表:
项目(PID,Pname,预算,DID)
部门(DID,Dname)
粗体= 主键
斜体= 外键
我想列出项目比部门营销多的部门。
这是我的代码:
select dname as "Division"
from division d, project p
where d.did = p.did
group by dname
having count(pid) >= all
(select count(p.pid)
from project p, division d
where p.did = d.did and d.dname = 'marketing')
我返回了正确的记录,但也返回了营销记录。如何从结果中排除营销记录?