- SELECT last_name FROM employees
WHERE last_name != ‘Lorentz’
START WITH last_name = ‘Lorentz’
CONNECT BY PRIOR manager_id=employee_id; - SELECT e.last_name, e.salary, d.department_name
FROM employees e JOIN departments d ON (e.department_id=d.department_id)
START WITH e.last_name = ‘Mourgos’
CONNECT BY PRIOR e.employee_id=e.manager_id; - SELECT e.last_name, e.employee_id, e.manager_id, d.department_name
FROM employees e JOIN departments d ON (e.department_id=d.department_id)
WHERE e.job_id !=’IT_PROG’
START WITH e.manager_id IS NULL
CONNECT BY PRIOR e.employee_id=e.manager_id AND e.last_name != ‘De Haan’; - SELECT e.last_name, e.employee_id, e.manager_id, d.department_name
FROM employees e JOIN departments d ON (e.department_id=d.department_Id)
WHERE last_name != ‘Chen’
START WITH e.manager_id = (SELECT manager_id FROM employees WHERE last_name=’Chen’)
CONNECT BY PRIOR e.employee_id=e.manager_id; - SELECT e.last_name, e.employee_id, e.manager_id, d.department_name, j.job_title
FROM employees e JOIN departments d ON (d.department_id=e.department_id)
JOIN jobs j ON (j.job_id=e.job_id)
WHERE e.department_id = (SELECT department_id FROM employees WHERE last_name=’Zlotkey’)
START WITH e.manager_id = (SELECT manager_id FROM employees WHERE last_name=’Zlotkey’)
CONNECT BY PRIOR e.employee_id=e.manager_id; - SELECT e.last_name, e.employee_id, e.manager_id, d.department_name, j.job_title
FROM employees e JOIN departments d ON (d.department_id=e.department_id)
JOIN jobs j ON (j.job_id=e.job_id)
WHERE (d.department_id,j.job_id) = (SELECT department_id, job_id FROM employees WHERE last_name=’Vargas’)
START WITH e.manager_id = (SELECT manager_id FROM employees WHERE last_name=’Vargas’)
CONNECT BY PRIOR e.employee_id=e.manager_id;
Tautan tugas : http://dedyrw.staff.telkomuniversity.ac.id/2014/05/13/task-hierarchical-retrieval/