X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0F532D1B1AA for ; Mon, 17 May 2004 04:26:34 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 77224-05 for ; Mon, 17 May 2004 04:26:11 -0300 (ADT) Received: from mail.cobweb.nl (mx1.cobweb.nl [80.242.96.4]) by svr1.postgresql.org (Postfix) with ESMTP id 76DDFD1B2C8 for ; Mon, 17 May 2004 04:26:07 -0300 (ADT) Received: from farcourier.com (dp3-26.dsl.cobweb.nl [193.67.120.154] (may be forged)) by mail.cobweb.nl (8.12.8/8.12.7) with ESMTP id i4H7QCu1074713 for ; Mon, 17 May 2004 09:26:13 +0200 (CEST) (envelope-from s.vanroye@farcourier.com) Subject: Re: a wierd query Date: Mon, 17 May 2004 09:25:52 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-ID: <71E201BE5E881C46811BA160694C5FCB046738@fs1000.farcourier.com> X-MS-Has-Attach: X-MIMEOLE: Produced By Microsoft Exchange V6.0.6249.0 Content-Class: urn:content-classes:message X-MS-TNEF-Correlator: Thread-Topic: [SQL] a wierd query Thread-Index: AcQ5AI4owP6tl52WQ0OfrpXPEpdSAAC3tbdw From: "Stijn Vanroye" To: Cc: "Edmund Bacon" X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200405/140 X-Sequence-Number: 17854 Are you sure about that Edmund? I have the following query: select distinct on (task_id, date) task_id, workhour_id, date from ( select task_id, workhour_id, begindate as date from workhour UNION select task_id, workhour_id, enddate as date from workhour )as dist1 which returns me 2763 rows in my case if I use the query without the top level select, like this: select task_id, workhour_id, begindate as date from workhour UNION select task_id, workhour_id, enddate as date from workhour I get 7146 rows. If I understand correctly there would be no need for the top level select i= f UNION would be to only return unique values. But given my test results th= is doesn't seem to be the case. Am I missing something or am I misinterpret= ing something? I mean I'm sure you get this information out of the document= ation, that's why this question has risen. Kind regards, Stijn Vanroye > -----Original Message----- > From: Edmund Bacon [mailto:ebacon@onesystem.com] > Sent: donderdag 13 mei 2004 17:28 > To: sad > Cc: pgsql-sql@postgresql.org > Subject: Re: [SQL] a wierd query >=20 >=20 > sad wrote: > > select distinct a as F from table > > union > > select distinct b as F from table; > > >=20 > Note that UNION only returns the unique values of the union > You can get repeated values by using UNION ALL. >=20 >=20 > --=20 > Edmund Bacon >=20 > ---------------------------(end of=20 > broadcast)--------------------------- > TIP 6: Have you searched our list archives? >=20 > http://archives.postgresql.org >=20