Re: a wierd query

Поиск
Список
Период
Сортировка
От sad
Тема Re: a wierd query
Дата
Msg-id 200405171112.49787.sad@bankir.ru
обсуждение исходный текст
Ответ на Re: a wierd query  ("Stijn Vanroye" <s.vanroye@farcourier.com>)
Список pgsql-sql
> I forgot one situation:
>
> if I run the query like so:
>       select distinct on (task_id, begindate) task_id, workhour_id,
> begindate as date from workhour UNION
>       select distinct on (task_id, enddate) task_id, workhour_id, enddate
> as date from workhour I get yet another value: 2961 rows.
>
> So I got 3 different result sets for 3 different ways to run the query.
> Even in this last case the UNION doesn't seem to only return unique values,
> and I will still need the top-level select.

if we suppose this situation possible to program in SQL
it causes data-loss in query
(i mean unpredictable query result:
if you have two records (f=1,b=2),(f=1,b=3)
"distinct ON f" makes a value of b meaningless)

So you MUST NOT select that way

P.S.  This situation means: you have wrong data structure.



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

Предыдущее
От: "Freddy Villalba Arias"
Дата:
Сообщение: problem with spanish characters
Следующее
От: "Stijn Vanroye"
Дата:
Сообщение: Re: a wierd query