You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, SQL doesn't actually operate this way. See this DB Fiddle Example for PostgreSQL. Please use the link and update the query to use both EXCEPT and EXCEPT ALL.
When you use EXCEPT (distinct), it will return the following table:
id
11
12
When you use EXCEPT ALL, it will return the following table:
id
10
11
12
As you can see, the use of DISTINCT does NOT perform the DISTINCT operation on the output of SQL_EXCEPT. It's a bit more complicated than that. Specifically, for EXCEPT DISTINCT, it executes DISTINCT on both inputs, then it runs EXCEPT on the new inputs. A similar thing occurs for INTERSECT.
The text was updated successfully, but these errors were encountered:
I believe there are some inconsistencies with the wording of RFC-0007 with regards to distinctness.
From the RFC:
However, SQL doesn't actually operate this way. See this DB Fiddle Example for PostgreSQL. Please use the link and update the query to use both
EXCEPT
andEXCEPT ALL
.When you use
EXCEPT
(distinct), it will return the following table:When you use
EXCEPT ALL
, it will return the following table:As you can see, the use of
DISTINCT
does NOT perform the DISTINCT operation on the output ofSQL_EXCEPT
. It's a bit more complicated than that. Specifically, forEXCEPT DISTINCT
, it executes DISTINCT on both inputs, then it runsEXCEPT
on the new inputs. A similar thing occurs forINTERSECT
.The text was updated successfully, but these errors were encountered: