SELECT last_name,salary
FROM employees
WHERE salary =(SELECTMIN(salary)FROM employees
);
查询平均工资最低的部门信息
#方法一SELECT*FROM departments
WHERE department_id=(SELECT department_id #找到idFROM(SELECT department_id,AVG(salary)平均工资
FROM employees
GROUPBY department_id
) 平均工资表
WHERE 平均工资=(SELECTMIN(平均工资) 最低平均工资
FROM(SELECT department_id,AVG(salary)平均工资
FROM employees
GROUPBY department_id
) 平均工资表
))#方式二SELECT*FROM departments
WHERE department_id =(SELECT department_id
FROM employees
GROUPBY department_id
ORDERBYAVG(salary)LIMIT1)
查询平均工资最低的部门信息和该部门的平均工资
#方式一:连接查询SELECT d.*, ag_dep.ag
FROM departments d
INNERJOIN(SELECTAVG(salary) ag,department_id
FROM employees
GROUPBY department_id
ORDERBY ag
LIMIT1) ag_dep
ON d.department_id = ag_dep.department_id
#方式二:子查询SELECT*,(SELECTAVG(salary)FROM employee