What is the function of the MINUS function in Oracle?
The MINUS function in Oracle is used to subtract the results of the second query from the results of the first query, returning rows that are present in the first query but not in the second query.
For example, let’s say there are two queries, Q1 and Q2. The MINUS function can be written as Q1 MINUS Q2, which will return the rows that exist in Q1 but not in Q2.
Here is an example.
SELECT col1, col2
FROM table1
MINUS
SELECT col1, col2
FROM table2;
This query will select data from columns col1 and col2 in table1, then subtract data from columns col1 and col2 in table2. The result will be the rows that exist in table1 but not in table2.