SELECT ed.first_name, ed.department_name
FROM (SELECT e.first_name, d.department_name
FROM employees e, departments d
WHERE d.department_id = e.department_id) ed
ORDER BY ed.first_name;
WITH Clause:
WITH emp_dept AS (
SELECT e.first_name, d.department_name
FROM employees e, departments d
WHERE d.department_id = e.department_id
)
SELECT ed.first_name, ed.department_name
FROM emp_dept ed
ORDER BY ed.first_name;
Views:
CREATE OR REPLACE VIEW emp_dept_join_v AS
SELECT e.first_name, d.department_name
FROM employees e, departments d
WHERE d.department_id = e.department_id;
SELECT ed.first_name, ed.department_name
FROM emp_dept_join_v ed
ORDER BY ed.first_name;
No comments:
Post a Comment