Good code is its own best documentation. As you're about to add a comment, ask yourself, 'How can I improve the code so that this comment isn't needed?' Improve the code and then document it to make it even clearer. Steve McConnell
The employee table contains the following fields
Name Null Type -------------- -------- ------------ EMPLOYEE_ID NOT NULL NUMBER(6) FIRST_NAME VARCHAR2(20) LAST_NAME NOT NULL VARCHAR2(25) EMAIL NOT NULL VARCHAR2(25) PHONE_NUMBER VARCHAR2(20) HIRE_DATE NOT NULL DATE JOB_ID NOT NULL VARCHAR2(10) SALARY NUMBER(8,2) COMMISSION_PCT NUMBER(2,2) MANAGER_ID NUMBER(6) DEPARTMENT_ID NUMBER(4)
The union uses to combine the result of two or more tables from the select statements. The union select statement should select the same number of fields in the result set. The UNION operator returns only distinct rows that appear in either result. The UNION ALL operator returns all rows from two result sets. The UNION ALL operator does not eliminate duplicate.
MINUS takes the first result set, and removes any that exist in the second result set; it also removes any duplicates.
The intersect return the results from two or more select statements.
-- UNION SELECT * FROM HR.employees WHERE DEPARTMENT_ID = 90 UNION SELECT * FROM HR.employees WHERE DEPARTMENT_ID = 60; -- MINUS SELECT * FROM HR.employees MINUS SELECT * FROM HR.employees WHERE DEPARTMENT_ID >= 60; -- INTERSECT SELECT * FROM HR.employees WHERE EMPLOYEE_ID IN (100, 103, 105) INTERSECT SELECT * FROM HR.employees WHERE EMPLOYEE_ID in (100, 102, 104, 105)