What is the usage of “minus” in sql?
In SQL, MINUS is a kind of set operator that removes rows from the first query result that appear in the second query result, returning only the rows that exist in the first query result.
For example:
SELECT column1, column2
FROM table1
MINUS
SELECT column1, column2
FROM table2;
This query will return rows that exist in table1 but not in table2. The MINUS operator can only be used when the two query results have the same number of columns and data types. In some database systems, MINUS can also be replaced with EXCEPT.