已知某 MySQL 数据库中,有表及其字段如下: Employee(员工)表,字段:ID(标识,主键)、Name(姓名)、DepartmentID(班级标识,外键) Department(部门)表,字段:ID(标识,主键)、Name(名称) 要查询各部门人数(包括空部门),可以使用的查询语句是:

发布于 2021-02-15 14:04:31
【单选题】
A SELECT Department.Name, COUNT(Employee.ID) '班级人数' FROM Department RIGHT JOIN Employee WHERE Department.ID = Employee.DepartmentID GROUP BY Department.Name, Employee.DepartmentID
B SELECT Department.Name, COUNT(Employee.ID) '班级人数' FROM Department RIGHT JOIN Employee ON Department.ID = Employee.DepartmentID GROUP BY Department.Name, Employee.DepartmentID
C SELECT Department.Name, COUNT(Employee.ID) '班级人数' FROM Department LEFT JOIN Employee WHERE Department.ID = Employee.DepartmentID GROUP BY Department.Name, Employee.DepartmentID
D SELECT Department.Name, COUNT(Employee.ID) '班级人数' FROM Department LEFT JOIN Employee ON Department.ID = Employee.DepartmentID GROUP BY Department.Name, Employee.DepartmentID

查看更多

关注者
0
被浏览
76
  • 体验AI问答!更聪明、超智能!
  • 一款基于GPT的超级AI助手,可以对话、创作、写文案!
1 个回答

撰写答案

请登录后再发布答案,点击登录

发布
问题

手机
浏览

扫码手机浏览

分享
好友

在线
客服