From: Tom Lane <tgl@sss.pgh.pa.us>
To: Aaron Bono <postgresql@aranya.com>
Cc: Postgres SQL language list <pgsql-sql@postgresql.org>
Subject: Re: Unions and Grouping
Date: Fri, 15 Dec 2006 16:42:04 -0500
Message-ID: <21818.1166218924@sss.pgh.pa.us> (raw)
In-Reply-To: <bf05e51c0612151315s59e6647etc2dd45e940d41a2a@mail.gmail.com>
References: <bf05e51c0612151315s59e6647etc2dd45e940d41a2a@mail.gmail.com>
"Aaron Bono" <postgresql@aranya.com> writes:
> My question, what do the SQL Specifications say should happen on a Union?
> Is it supposed to eliminate duplicates even WITHIN the individual queries
> that are being unioned?
Yes. SQL92 7.10 saith:
b) If a set operator is specified, then the result of applying
the set operator is a table containing the following rows:
i) Let R be a row that is a duplicate of some row in T1 or of
some row in T2 or both. Let m be the number of duplicates
of R in T1 and let n be the number of duplicates of R in
T2, where m >= 0 and n >= 0.
ii) If ALL is not specified, then
Case:
1) If UNION is specified, then
Case:
A) If m > 0 or n > 0, then T contains exactly one dupli-
cate of R.
B) Otherwise, T contains no duplicate of R.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, postgresql@aranya.com
Subject: Re: Unions and Grouping
In-Reply-To: <21818.1166218924@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox