distinct
explicitlydistinct
not supportedminus
The table operator except [distinct]
returns the rows of the first result except those that are also in the second.
SELECT …
FROM …
EXCEPT DISTINCT
SELECT …
FROM …
As with all table operators both sides of except
must have the same number of columns and their types must be compatible based on their position (see corresponding
). All null
values are considered being the same (not distinct) for this operation.
If a row exists in the second result it will not appear in the final result—not even if it is multiple times in the first result.
Other table operators:
Union: union [distinct]
, union all
Intersect: intersect [distinct]
, intersect all
The except [distinct]
operator is defined in ISO/IEC 9075-2 as the mandatory feature E071-03, “EXCEPT DISTINCT table operator”.
The essence of SQL tuning in 200 pages
Buy on Amazon
(paperback only)
Paperback and PDF also available at Markus’ store.
Markus offers SQL training and consulting for developers working at companies of any size.
Learn more »