[ DE ]

EXCEPT [DISTINCT] (table operator)


BigQueryDb2 (LUW)DuckDBH2MariaDBMySQLOracle DBPostgreSQLSQL ServerSQLite200820102012201420162018202020222024⚠ 3.5.7 - 3.51.0b⚠ 2008R2 - 2025b✓ 8.3 - 18✓ 21c - 23.26.0a⊘ 11gR1 - 19ca✓ 8.0.31 - 9.5.0⊘ 5.0 - 8.0.30✓ 10.5 - 12.1.2b⚠ 10.4b✓ 10.3⊘ 5.1 - 10.2⚠ 1.4.191 - 2.4.240b✓ 1.0.0 - 1.4.0⚠ 9.7 - 12.1.3b⚠ 2.0c
  1. Non-standard alternative: minus
  2. Explicit keyword distinct not supported
  3. Requires the keyword distinct explicitly

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.

Normative References

The except [distinct] operator is defined in ISO/IEC 9075-2:2023 as the mandatory feature E071-03, "EXCEPT DISTINCT table operator".

You can’t catch up on 20 years of SQL evolution in one day. Subscribe the newsletter via E-Mail , Bluesky or RSS to gradually catch up and to keep modern-⁠sql.com on your radar.

About the Author

[画像:Photo of Markus Winand]

Markus Winand provides insights into SQL and shows how different systems support it at modern-sql.com. Previously he made use-the-index-luke.com, which is still actively maintained. Markus can be hired as trainer, speaker and consultant via winand.at.

Buy the Book

Cover of "SQL Performance Explained": Squirrel running on grass

The essence of SQL tuning in 200 pages

Buy now!
(paperback and/or PDF)

Paperback also available at Amazon.com.

Hire Markus

Markus offers SQL training and consulting for developers working at companies of all sizes.
Learn more »

Connect with Markus Winand

Subscribe mailinglists Subscribe the RSS feed Markus Winand on LinkedIn Markus Winand on XING Markus Winand on Twitter Markus Winand on Bluesky
Copyright 2015-2026 Markus Winand. All righs reserved.
Legal | Contact | NO WARRANTY | Trademarks | Privacy and GDPR

AltStyle によって変換されたページ (->オリジナル) /