0% found this document useful (0 votes)
2 views1 page

TD 3

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

TD 3

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

/* 1.

Trouver les départements sans employés */

-- Utilisation de MINUS
SELECT *
FROM departments
WHERE department_id IN (
SELECT department_id
FROM departments
MINUS
SELECT department_id
FROM employees
);

-- Utilisation de NOT IN
SELECT *
FROM departments
WHERE department_id NOT IN (
SELECT department_id
FROM employees
WHERE department_id IS NOT NULL
);

-- Utilisation de LEFT JOIN


SELECT d.*
FROM departments d
LEFT JOIN employees e
ON d.department_id = e.department_id
WHERE e.employee_id IS NULL;

/* 2. Trouver l'employé avec le salaire minimum */


SELECT *
FROM employees
WHERE salary = (
SELECT MIN(salary)
FROM employees
);

/* 3. Trouver les employés ayant le même manager que l'employé avec employee_id =
110 */
SELECT *
FROM employees
WHERE manager_id = (
SELECT manager_id
FROM employees
WHERE employee_id = 110
);

You might also like