嘿伙计们,我一直在努力,但我无法解决这个问题。请问有人可以帮我吗?我只是困惑,有人可以帮助我如何修复代码?对于内容感到抱歉,因为我无法上传图片。
SELECT Employee.EmpName, Employee.Age
FROM Employee
WHERE Employee.Age < (SELECT COUNT(Employee.EmployeeID)
FROM Employee, Department
WHERE Department.ManagerID = Employee.EmployeeID
GROUP BY Employee.EmployeeID
HAVING COUNT(Employee.EmployeeID) >= 2)
//(问题)找到管理多个部门的最年轻的经理。查询返回经理的姓名和年龄。
SCHEMA
Employee(EmployeeID:Integer, EmpName: String, Age: Integer, Salary: Real)
Department(DeptID: Integer, DeptName:String, Budget: Real, ManagerID: Integer)
Works(EmployeeID:Integer, DeptID: Integer, Percent_Time: Integer)
答案 0 :(得分:0)
试试这个
SELECT e2.EmpName, e2.Age
FROM Employee e2
JOIN Works w2 USING (EmployeeID)
JOIN (SELECT w.DeptID, MIN(e.Age) AS Youngest
FROM Works w
INNER JOIN Employee e USING (EmployeeID)
GROUP BY w.DeptID) sq
ON w2.DeptID = sq.DeptID and e2.Age = sq.Youngest