您好,登錄后才能下訂單哦!
#案例:返回location_id是1400或1700的部門中的所有員工
SELECT last_name
FROM employees
WHERE department_id IN(
SELECT DISTINCT department_id
FROM departments
WHERE location_id IN (1400,1700)
);
#案例:返回其他工種中比job_id為'IT_PROG'部門任一工資低的員工的員工號、姓名、job_id和salary
SELECT DISTINCT employee_id,last_name,job_id,salary
FROM employees
WHERE salary<ANY(
SELECT DISTINCT salary
FROM employees
WHERE job_id='IT_PROG'
) AND job_id <>'IT_PROG' ;
或者
SELECT DISTINCT employee_id,last_name,job_id,salary
FROM employees
WHERE salary<(
SELECT DISTINCT MAX(salary)
FROM employees
WHERE job_id='IT_PROG'
) AND job_id <>'IT_PROG' ;
#案例:返回其他工種中比job_id為'IT_PROG'部門所有工資低的員工的員工號、姓名、job_id和salary
SELECT DISTINCT employee_id,last_name,job_id,salary
FROM employees
WHERE salary<ALL(
SELECT DISTINCT salary
FROM employees
WHERE job_id='IT_PROG'
) AND job_id <>'IT_PROG' ;
或者
SELECT DISTINCT employee_id,last_name,job_id,salary
FROM employees
WHERE salary<(
SELECT DISTINCT MIN(salary)
FROM employees
WHERE job_id='IT_PROG'
) AND job_id <>'IT_PROG' ;
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。