EXCEPT operator in Redshift Database

EXCEPT operator is used to compare the result sets of 2 queries . It returns rows from first query that are not in the second query; similar to MINUS operator in Oracle. In Redshift, EXCEPT and MINUS are synonyms.

Syntax:

Both the below queries return the same output.

SELECT col11,col12,col13 from table1
EXCEPT
SELECT col21,col22,col23 from table2;
SELECT col11,col12,col13 from table1
MINUS
SELECT col21,col22,col23 from table2;

Both the select statements should have the same number of columns and same data types.

See also  How to list all S3 buckets and contents of a bucket