From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
---|---|
To: | Stijn Vanroye <s(dot)vanroye(at)farcourier(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org, Edmund Bacon <ebacon(at)onesystem(dot)com> |
Subject: | Re: a wierd query |
Date: | 2004-05-17 15:01:07 |
Message-ID: | 20040517075834.H21709@megazone.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Mon, 17 May 2004, Stijn Vanroye wrote:
> 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
This gets you first rows distincted by task_id, workhour_id and date
and then only rows distincted by task_id and date (and an unpredictable
workhour_id).
> 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
This gets rows distincted by task_id, workhour_id and date.
From | Date | Subject | |
---|---|---|---|
Next Message | PS PS | 2004-05-17 16:37:36 | Max Columns in a SQL Select |
Previous Message | Kornelije | 2004-05-17 14:58:13 | Replace function ... |