From: Stijn Vanroye <s.vanroye@farcourier.com>
To: pgsql-sql@postgresql.org
Cc: Stephan Szabo <sszabo@megazone.bigpanda.com>
Subject: Re: a wierd query
Date: Tue, 18 May 2004 09:56:29 +0200
Message-ID: <71E201BE5E881C46811BA160694C5FCB04673A@fs1000.farcourier.com> (raw)
I understand, thanks.
First: as I said in my previous post, the workhour_id was left behind by mistake and has since been removed.
So it seems that I can ommit the distinct completely and just use the query in it's simpelest form, like this:
select employee_id, begindate as date from workhour
UNION
select employee_id, enddate as date from workhour
And I would get a list of all dates (as well begin- as enddates) where a date can occure only once with each employee?
Altough I didn't start this thread I'm learing some usefull things here, so some thanks to the people who replied (and started the thread) are in place here.
Kind regards,
Stijn Vanroye
> -----Original Message-----
> From: Stephan Szabo [mailto:sszabo@megazone.bigpanda.com]
> Sent: maandag 17 mei 2004 17:01
> To: Stijn Vanroye
> Cc: pgsql-sql@postgresql.org; Edmund Bacon
> Subject: Re: [SQL] a wierd query
>
> 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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: s.vanroye@farcourier.com, sszabo@megazone.bigpanda.com
Subject: Re: a wierd query
In-Reply-To: <71E201BE5E881C46811BA160694C5FCB04673A@fs1000.farcourier.com>
References: <71E201BE5E881C46811BA160694C5FCB04673A@fs1000.farcourier.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