【发布时间】:2013-11-19 20:10:23
【问题描述】:
我有两个具有以下属性的表:
表:部门
dept_nbr
部门名称
部门电话
部门建筑
部门经理
表:员工
emp_nbr
emp_lname
emp_fname
emp_phone
emp_dateofbirth
emp_date_hired
emp_nbr_of_dependents
emp_dept
dept_nbr = emp_dept
我需要:
每个部门
1.) 总数。员工家属
2.) 平均数。的家属。 - 我猜是AVG
3.) 总数。员工人数 - 我猜是 count(*)
有人可以帮我解决这个问题吗?以下是我的代码
select DEPT_NAME, AVG(EMP_NBR_OF_DEPENDENTs), count(emp_fname) as Total_No_of_Employees from dept,employee where DEPT_NBR = EMP_DEPT group by DEPT_NAME;
第二部分:
包括员工人数少于 50 人的部门
select DEPT_NAME, AVG(EMP_NBR_OF_DEPENDENTs), count(emp_fname) as Total_No_of_Employees from dept,employee where DEPT_NBR in (select EMP_DEPT from employee where count(emp_fname)<50) group by DEPT_NAME ;
我尝试了上述方法并收到错误 1111
谢谢大家
【问题讨论】:
-
你所尝试的,你猜到的,你应用了什么
-
您是否尝试过解决您面临的问题,或者您希望我们为您编写程序代码?
-
我已经添加了到目前为止我尝试过的内容。它给了我输出..但我不知道它是否准确/最好的方法。感谢您查看问题