一个多重嵌套的SQL查询例子

下面是一个多重嵌套的SQL SELECT语句

SELECT d.department_name, e.employee_name 
FROM department d
INNER JOIN employee e ON d.department_id = e.department_id
WHERE d.department_id IN (
    SELECT department_id 
    FROM department 
    WHERE location = '北京'
) AND e.salary > (
    SELECT AVG(salary) 
    FROM employee 
    WHERE department_id = d.department_id
)
ORDER BY d.department_name, e.employee_name;

已发布

分类

标签:

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注