1.使用内连接方法查找不在财务部工作的所有员工信息。 2.查询研发部在1976年以前出生的雇员姓名及薪水详情。 3.查找员工数超过2人的部门名称和员工数量。 4.用子查询查找在财务部工作的雇员情况。 5.用子查询的方法查找所有收入在2500元以下的雇员的情况。
时间: 2024-03-19 08:43:03 浏览: 90
情境四-公司管理数据库系统的查询.doc
1.使用内连接方法查找不在财务部工作的所有员工信息。
```
SELECT Employee.*
FROM Employee
INNER JOIN Department ON Employee.DepartmentID = Department.DepartmentID
WHERE Department.DepartmentName != '财务';
```
2.查询研发部在1976年以前出生的雇员姓名及薪水详情。
```
SELECT Employee.EmployeeName, Salary.MonthlySalary
FROM Employee
INNER JOIN Salary ON Employee.EmployeeID = Salary.EmployeeID
WHERE Employee.DepartmentID = '研发' AND Employee.Birthdate < '1976-01-01';
```
3.查找员工数超过2人的部门名称和员工数量。
```
SELECT Department.DepartmentName, COUNT(*) AS employee_count
FROM Employee
INNER JOIN Department ON Employee.DepartmentID = Department.DepartmentID
GROUP BY Department.DepartmentName
HAVING employee_count > 2;
```
4.用子查询查找在财务部工作的雇员情况。
```
SELECT *
FROM Employee
WHERE DepartmentID = (SELECT DepartmentID FROM Department WHERE DepartmentName = '财务');
```
5.用子查询的方法查找所有收入在2500元以下的雇员的情况。
```
SELECT *
FROM Employee
WHERE EmployeeID IN (SELECT EmployeeID FROM Salary WHERE MonthlySalary <= 2500);
```
阅读全文