ORACLE | ||||||||
| ||||||||
| ||||||||
| ||||||||
| ||||||||
| ||||||||
| ||||||||
| ||||||||
|
Oracle - Minus
In Oracle, MINUS operator is used to return all rows in the first SELECT statement that are not returned by the second SELECT statement.
Each SELECT statement has a dataset and the MINUS operator returns all documents from the first dataset and then removes all documents from the second dataset.
SELECT expression1, expression2, ... expression_n
FROM table1
WHERE conditions
MINUS
SELECT expression1, expression2, ... expression_n
FROM table2
WHERE conditions;
Note: The expressions must be same in number for both the SELECT statement and have similar datatype.
This example will return one field with the same datatype from two tables "suppliers" and "order_details".
SELECT supplier_id
FROM suppliers
MINUS
SELECT supplier_id
FROM order_details;
SUPPLIER_ID |
---|
20 |
21 |
22 |
25 |
28 |
30 |
31 |
50 |