EXCEPT
Example
Section titled “Example”SELECT column_name FROM table1EXCEPTSELECT column_name FROM table2;Output
Section titled “Output”| column_name ||-------------|| Value 1 || Value 3 |Explanation
Section titled “Explanation”The EXCEPT operator is used to return all the distinct rows from the first SELECT statement that are not returned by the second SELECT statement. In the given example, it is retrieving distinct rows from table1 that are not present in table2 based on the column_name specified.
Example
Section titled “Example”SELECT department_idFROM employeesEXCEPTSELECT department_idFROM departments;Output
Section titled “Output”| DEPARTMENT_ID ||---------------|| 270 || 340 |Explanation
Section titled “Explanation”The EXCEPT operator returns records from the first SELECT statement (employees table) that are not matched by the second SELECT statement (departments table). In the example given, we are obtaining the department_ids from the employees table that do not exist in the departments table.