考虑如下所示的关系数据库模式,主码加了下划线,使用SQL语句写出以下查询。 Employee(person_name, street, city) Works(person_name, company_name, salary) Company(company_name, city) Manages(person_name, manager_name) 1、找出“Baidu Corporation”公司中所有薪水超过100万的员工信息。 2、找出所有担任经理职务的员工的名字。 3、找出所有被“Hans Write”管理的员工的名字。 4、列出各个公司员工薪水的总数。 5、找出居住在威海市“Wenhua West Road”的员工所在的所有公司的名字。 6、找出与其经理居住在同一城市同一街道的所有员工的姓名。 7、找出不在“Baidu Corporation”工作的所有员工的姓名。 8、找出所有经理管理的员工人数都不超过10人的公司名。
时间: 2023-05-13 17:06:36 浏览: 300
1、SELECT person_name FROM Works WHERE company_name='Baidu Corporation' AND salary>1000000;
2、SELECT person_name FROM Manages;
3、SELECT person_name FROM Manages WHERE manager_name='Hans Write';
4、SELECT Company.company_name, SUM(Works.salary) FROM Company JOIN Works ON Company.company_name=Works.company_name GROUP BY Company.company_name;
5、SELECT DISTINCT Company.company_name FROM Company JOIN Works ON Company.company_name=Works.company_name JOIN Employee ON Works.person_name=Employee.person_name WHERE Employee.city='威海市' AND Employee.street='Wenhua West Road';
6、SELECT DISTINCT Employee.person_name FROM Employee JOIN Manages ON Employee.person_name=Manages.person_name JOIN Employee AS Manager ON Manages.manager_name=Manager.person_name WHERE Employee.city=Manager.city AND Employee.street=Manager.street;
7、SELECT person_name FROM Employee WHERE person_name NOT IN (SELECT person_name FROM Works WHERE company_name='Baidu Corporation');
8、SELECT Company.company_name FROM Company JOIN Manages ON Company.company_name=Manages.company_name GROUP BY Company.company_name HAVING COUNT(*)<=10;
阅读全文