#案例:返回location_id是1400或1700的部門中的所有員工
創(chuàng)新互聯(lián)是一家以成都網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)、品牌設(shè)計(jì)、軟件運(yùn)維、seo優(yōu)化排名、小程序App開發(fā)等移動開發(fā)為一體互聯(lián)網(wǎng)公司。已累計(jì)為成都橡塑保溫等眾行業(yè)中小客戶提供優(yōu)質(zhì)的互聯(lián)網(wǎng)建站和軟件開發(fā)服務(wù)。
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'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'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' ;