问题是:你有一张员工表。你必须选择只有一位女性工作的部门。
表属性是fname,lname,ssn,gender,dno,salary。
我的代码是:
select dno
from employee
where (select count(*)
from employee
where gender='f'
group by dno)
= 1 ;
我哪里错了?
答案 0 :(得分:0)
您可以将group by与having
子句
select dno,count(*) as theCount
from employee
where gender='f'
group by dno
having theCount=1