您好,这是数据库结构。
employee (employee-name, street, city)
works (employee-name, company-name, salary)
company (company-name, city)
manages (employee-name, manager-name)
我需要获取以下详细信息,但根据我的培训师的说法,任何人都可以告诉我以下查询有什么问题吗?
查找在 First Bank Corporation 工作且收入超过 10,000 美元的所有员工的姓名、街道地址和居住城市。
SELECT e.employee-name, e.city
FROM employee e
INNER JOIN works w
ON e.employee-name = w.employee-name
AND w.company-name = “First Bank Corporation”
GROUP BY e.employee-name
HAVING w.salary > 10000
在数据库中查找与他们工作的公司居住在同一城市的所有员工。
SELECT e.employee-name
FROM employee e
INNER JOIN works w
ON e.employee-name = w.emploee-name
INNER JOIN company c
ON w.company-name = c.company-name
GROUP BY e.employee-name
HAVING e.city = c.city
在数据库中查找与其经理居住在同一城市和同一街道上的所有员工。
SELECT employee-name, street, city
FROM employee
INTERSECT
SELECT e.employee-name, e.street, e.city
FROM employee e, manages m
WHERE e.employee-name = m.manager-name