From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Stijn Vanroye <s.vanroye@farcourier.com>
Cc: pgsql-sql@postgresql.org, Edmund Bacon <ebacon@onesystem.com>
Subject: Re: a wierd query
Date: Mon, 17 May 2004 08:01:07 -0700 (PDT)
Message-ID: <20040517075834.H21709@megazone.bigpanda.com> (raw)
In-Reply-To: <71E201BE5E881C46811BA160694C5FCB046738@fs1000.farcourier.com>
References: <71E201BE5E881C46811BA160694C5FCB046738@fs1000.farcourier.com>
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.
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: sszabo@megazone.bigpanda.com, s.vanroye@farcourier.com, ebacon@onesystem.com
Subject: Re: a wierd query
In-Reply-To: <20040517075834.H21709@megazone.bigpanda.com>
* 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