为什么这个语句本身有效,但当它是子查询的一部分时,它表示无效使用组函数
select count(cid)
from qualification q
inner join faculty f
on q.fid=f.fid
where fname='Berry'
group by
f.fid;
我如何修改它以适应子查询?
整个查询 -
select fid, fname from faculty
where fid in
(select fid from qualification where count(cid)=
(select count(cid) from qualification q inner join faculty f on
q.fid=f.fid where fname='Berry' group by f.fid));
逻辑:列出所有能够教授Berry教授可以教授的所有课程的教师的fname和fid
答案 0 :(得分:1)
对我来说,问题是在count()
WHERE
where count(cid)=
(select count(cid) from qualification q inner join faculty f on
q.fid=f.fid where fname='Berry' group by f.fid)
您可以尝试将其更改为像这样处理
HAVING count(cid)=
(select count(cid) from qualification q inner join faculty f on
q.fid=f.fid where fname='Berry' group by f.fid)
但我不理解逻辑。如果您解释得更多,我们会建议更好的解决方案