Category Archives: Uncategorized

Task Hierarchical Retrieval Solutions

Soal klik disini !

1.
SELECT last_name
FROM employees
WHERE last_name != ‘Lorentz’
START WITH last_name = ‘Lorentz’
CONNECT BY PRIOR manager_id = employee_id;

2.
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;

3.
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’;

4.
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;

5.
SELECT e.last_name, e.employee_id, e.manager_id, d.department_name, j.job_title
FROM departments d JOIN employees e
ON (d.department_id = e.department_id)
JOIN jobs j
ON (e.job_id = j.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;

6.
select e.last_name, e.employee_id, e.manager_id, d.department_name, j.job_title
from departments d join employees e on (d.department_id = e.department_id)
join jobs j on(e.job_id = j.job_id)
where (e.department_id, e.job_id) IN (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.manager_id = e.employee_id;