Reputation: 61
I am trying to do MINUS on 2 tables which have same schema in big-query.As I understand MINUS is not working in biquery
Upvotes: 0
Views: 6155
Reputation: 61
I see that there is EXCEPT set operator in Big Query for Standard SQL.
The EXCEPT operator returns rows from the left input query that are not present in the right input query. This is similar to what the MINUS does in ORACLE/MySQL
SELECT fieldId from dataset.table1
except DISTINCT SELECT fieldId from dataset.table2
Note: the datatype of both the columns should be same in both the tables
Upvotes: 1
Reputation: 11797
You can do something like:
SELECT
field
FROM `project_id.dataset.tableA` A
WHERE NOT EXISTS(SELECT 1 FROM `project_id.dataset.tableB` b WHERE a.field = b.field)
Upvotes: 1