如何查询员工ID为1001的信息? 如何查询所有员工的姓名和工资? 如何查询所有员工的入职日期和所在部门? 如何查询所有员工的年龄和性别? 如何查询所有男性员工的信息? 如何查询所有工资大于等于5000的员工信息? 如何查询所有工资在4000到6000之间的员工信息? 如何查询所有入职日期在2019年的员工信息? 如何查询所有职位为经理的员工信息? 如何查询所有在部门D1工作的员工信息? 如何查询所有在部门D1或D2工作的员工信息? 如何查询所有员工的工资总和? 如何查询所有员工的平均工资? 如何查询所有部门的员工总数? 如何查询所有部门的平均工资? 如何查询所有部门的最高工资? 如何查询所有部门的最低工资? 如何查询所有员工的最高工资? 如何查询所有员工的最低工资? 如何查询所有员工的工资排名?
时间: 2024-02-12 13:06:44 浏览: 212
1. 如何查询员工ID为1001的信息?
```
SELECT * FROM employees WHERE id = 1001;
```
2. 如何查询所有员工的姓名和工资?
```
SELECT name, salary FROM employees;
```
3. 如何查询所有员工的入职日期和所在部门?
```
SELECT hire_date, department FROM employees;
```
4. 如何查询所有员工的年龄和性别?
```
SELECT age, gender FROM employees;
```
5. 如何查询所有男性员工的信息?
```
SELECT * FROM employees WHERE gender = 'Male';
```
6. 如何查询所有工资大于等于5000的员工信息?
```
SELECT * FROM employees WHERE salary >= 5000;
```
7. 如何查询所有工资在4000到6000之间的员工信息?
```
SELECT * FROM employees WHERE salary BETWEEN 4000 AND 6000;
```
8. 如何查询所有入职日期在2019年的员工信息?
```
SELECT * FROM employees WHERE YEAR(hire_date) = 2019;
```
9. 如何查询所有职位为经理的员工信息?
```
SELECT * FROM employees WHERE title = 'Manager';
```
10. 如何查询所有在部门D1工作的员工信息?
```
SELECT * FROM employees WHERE department = 'D1';
```
11. 如何查询所有在部门D1或D2工作的员工信息?
```
SELECT * FROM employees WHERE department IN ('D1', 'D2');
```
12. 如何查询所有员工的工资总和?
```
SELECT SUM(salary) FROM employees;
```
13. 如何查询所有员工的平均工资?
```
SELECT AVG(salary) FROM employees;
```
14. 如何查询所有部门的员工总数?
```
SELECT department, COUNT(*) FROM employees GROUP BY department;
```
15. 如何查询所有部门的平均工资?
```
SELECT department, AVG(salary) FROM employees GROUP BY department;
```
16. 如何查询所有部门的最高工资?
```
SELECT department, MAX(salary) FROM employees GROUP BY department;
```
17. 如何查询所有部门的最低工资?
```
SELECT department, MIN(salary) FROM employees GROUP BY department;
```
18. 如何查询所有员工的最高工资?
```
SELECT MAX(salary) FROM employees;
```
19. 如何查询所有员工的最低工资?
```
SELECT MIN(salary) FROM employees;
```
20. 如何查询所有员工的工资排名?
```
SELECT id, name, salary, FIND_IN_SET(salary, (SELECT GROUP_CONCAT(DISTINCT salary ORDER BY salary DESC) FROM employees)) AS rank FROM employees ORDER BY rank;
```
阅读全文