Re: a wierd query

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: a wierd query
Дата
Msg-id 20040517075834.H21709@megazone.bigpanda.com
обсуждение исходный текст
Ответ на Re: a wierd query  ("Stijn Vanroye" <s.vanroye@farcourier.com>)
Список 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.


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Stijn Vanroye"
Дата:
Сообщение: Re: a wierd query
Следующее
От: PS PS
Дата:
Сообщение: Max Columns in a SQL Select